1
00:00:00,000 --> 00:00:02,000
So, guys, uh, till here.

2
00:00:02,000 --> 00:00:03,000
Now, we have seen each and every thing.

3
00:00:03,000 --> 00:00:07,000
We have trained our entire an, uh, artificial neural network.

4
00:00:07,000 --> 00:00:08,000
We got the loss.

5
00:00:08,000 --> 00:00:10,000
The loss was also very less.

6
00:00:10,000 --> 00:00:15,000
We saw the loss in our TensorBoard, uh, visualized the entire diagram.

7
00:00:15,000 --> 00:00:16,000
We saw various parameters.

8
00:00:16,000 --> 00:00:19,000
Then we went ahead and did the prediction.

9
00:00:19,000 --> 00:00:21,000
We saved all the pickle file.

10
00:00:21,000 --> 00:00:22,000
We loaded all the pickle file.

11
00:00:22,000 --> 00:00:25,000
And, you know, we could also see the prediction was also happening.

12
00:00:25,000 --> 00:00:26,000
Everything.

13
00:00:26,000 --> 00:00:26,000
We did it.

14
00:00:26,000 --> 00:00:30,000
Now it's time that we create one app.py file.

15
00:00:30,000 --> 00:00:34,000
And this is what I'm going to specifically use as my Streamlit web app.

16
00:00:34,000 --> 00:00:39,000
I'm going to probably create an end to end web app, where I will be able to give the inputs and do

17
00:00:39,000 --> 00:00:40,000
the prediction from there.

18
00:00:41,000 --> 00:00:44,000
So let's go ahead and here is my app.py.

19
00:00:44,000 --> 00:00:48,000
So first of all I need to import all the libraries that I really require.

20
00:00:48,000 --> 00:00:53,000
So one is streamlit as st numpy tensorflow sklearn.preprocessing.

21
00:00:53,000 --> 00:00:57,000
I'm going to use standard scalar labelencoder onehotencoder.

22
00:00:57,000 --> 00:01:02,000
So whatever things we specifically did in the prediction dot ipynb file, we'll be doing it okay.

23
00:01:03,000 --> 00:01:09,000
So the first step is loading the loading the trained model.

24
00:01:09,000 --> 00:01:13,000
So I'll go ahead and write tf dot Keras.models dot load underscore model.

25
00:01:13,000 --> 00:01:16,000
And I will be giving my model dot h5 file name.

26
00:01:16,000 --> 00:01:22,000
Um, then, uh, what we will do is that we will go ahead and load all our encoder scaler.

27
00:01:23,000 --> 00:01:26,000
Um, you know, one hot encoder, all the files itself.

28
00:01:26,000 --> 00:01:29,000
So here you have one hot encoder G0 dot pickle file.

29
00:01:29,000 --> 00:01:31,000
And I'm encoding this.

30
00:01:31,000 --> 00:01:36,000
So here you can see one hot encoder underscore geo dot pickle I am loading this in the read byte mode.

31
00:01:36,000 --> 00:01:38,000
Then I have this pickle dot load.

32
00:01:38,000 --> 00:01:40,000
Then I'm also loading this scaler.

33
00:01:40,000 --> 00:01:40,000
Right.

34
00:01:40,000 --> 00:01:44,000
So all this pickle is specifically getting loaded right now.

35
00:01:44,000 --> 00:01:46,000
Let's quickly start with the Streamlit app.

36
00:01:46,000 --> 00:01:52,000
So here I'm going to use a Streamlit app because I don't have to worry about HTML and all.

37
00:01:52,000 --> 00:01:53,000
So that is the reason I'm using this.

38
00:01:53,000 --> 00:01:55,000
So I'll go ahead and write this t dot title.

39
00:01:56,000 --> 00:02:03,000
Let me go ahead and write customer churn prediction okay.

40
00:02:03,000 --> 00:02:07,000
So customer churn prediction I'm going to use over here.

41
00:02:09,000 --> 00:02:10,000
Customer churn prediction.

42
00:02:10,000 --> 00:02:13,000
So this will basically be my title of the Streamlit app.

43
00:02:13,000 --> 00:02:19,000
Now see you know that how many types of inputs you are specifically giving you are giving geography

44
00:02:19,000 --> 00:02:25,000
gender age, balance, credit score, estimated salary, tenure, number of products has credit card

45
00:02:25,000 --> 00:02:28,000
or number of uh uh, number of products already mentioned.

46
00:02:28,000 --> 00:02:29,000
Right.

47
00:02:29,000 --> 00:02:30,000
Is active member.

48
00:02:30,000 --> 00:02:31,000
Also these are some of the features.

49
00:02:31,000 --> 00:02:36,000
So based on these features I need to provide my input from the Streamlit web page.

50
00:02:36,000 --> 00:02:39,000
So for this we will go ahead and create all these inputs.

51
00:02:39,000 --> 00:02:44,000
So for geography I'll be using uh drop down uh which will be specifically using all the categories.

52
00:02:44,000 --> 00:02:47,000
So categories of zero whichever is the categories of zero.

53
00:02:47,000 --> 00:02:49,000
By default it will get loaded.

54
00:02:49,000 --> 00:02:54,000
Over here it can be zero, one, two or any name that we are going to give over here.

55
00:02:54,000 --> 00:03:00,000
Then you have this dot select box, whatever values or with respect to the classes that I have I'm actually

56
00:03:00,000 --> 00:03:01,000
able to get it over here.

57
00:03:02,000 --> 00:03:06,000
Um, then uh you'll also be able to see HD dot slider.

58
00:03:06,000 --> 00:03:08,000
I'm using a slider for age.

59
00:03:09,000 --> 00:03:13,000
I'm using a input for balance credit score, HD underscore number, credit score.

60
00:03:13,000 --> 00:03:16,000
Estimated salary is again number underscore input.

61
00:03:16,000 --> 00:03:21,000
Then for tenure again I'm using a three dot slider between 0 to 10.

62
00:03:21,000 --> 00:03:26,000
Uh, I'm also using a slider for number of products and similarly has credit card and is active number.

63
00:03:26,000 --> 00:03:27,000
Okay.

64
00:03:27,000 --> 00:03:30,000
So this is what is the input data I will be giving from my user input.

65
00:03:30,000 --> 00:03:36,000
Then I will prepare this input data by taking it in some kind of dictionary.

66
00:03:36,000 --> 00:03:36,000
Right.

67
00:03:36,000 --> 00:03:39,000
So we will go ahead and prepare this dictionary.

68
00:03:39,000 --> 00:03:43,000
So here I have my credit score I'll take this data gender I'm going to use this labelencoder gender

69
00:03:43,000 --> 00:03:48,000
and use uh transformer uh transform and probably get the zeroth value.

70
00:03:48,000 --> 00:03:49,000
Then age is here.

71
00:03:49,000 --> 00:03:52,000
Ten year is here, balance is here, number is here.

72
00:03:52,000 --> 00:03:55,000
And each and everything, all the informations are specifically here.

73
00:03:55,000 --> 00:03:56,000
Okay.

74
00:03:56,000 --> 00:03:59,000
Now, uh, one more information that is missing.

75
00:03:59,000 --> 00:04:04,000
Uh, is basically our, um, one hot encoder, which is my geographic column.

76
00:04:04,000 --> 00:04:10,000
So for geography I will try to encode it in a different way, like how I did it in my prediction dot

77
00:04:10,000 --> 00:04:11,000
ipynb file.

78
00:04:11,000 --> 00:04:14,000
So I will just go ahead and encode this geography.

79
00:04:14,000 --> 00:04:15,000
So here is my geo encoded.

80
00:04:15,000 --> 00:04:18,000
I'll take this geography value which is from here.

81
00:04:18,000 --> 00:04:20,000
Write this geography value.

82
00:04:20,000 --> 00:04:21,000
I will take this in the form of list.

83
00:04:21,000 --> 00:04:26,000
I'll convert this into an array by using one hot encoder dot underscore geo dot transform.

84
00:04:26,000 --> 00:04:33,000
Then I'm converting back into a data frame by taking the feature out feature names over here.

85
00:04:33,000 --> 00:04:33,000
Right.

86
00:04:33,000 --> 00:04:38,000
So, uh, this is what I am actually specifically getting for all my values.

87
00:04:38,000 --> 00:04:42,000
Now I will combine this one hot encoded with my input data.

88
00:04:43,000 --> 00:04:43,000
Right.

89
00:04:43,000 --> 00:04:48,000
So for that again we'll go ahead and write pd dot contact concat I'm saying input data dot reset index

90
00:04:48,000 --> 00:04:49,000
drop is equal to true.

91
00:04:49,000 --> 00:04:53,000
Then take the geo underscore coded and encoded underscore df with access is equal to one.

92
00:04:53,000 --> 00:04:57,000
Same thing what we did in the prediction dot ipynb file.

93
00:04:57,000 --> 00:04:57,000
Right.

94
00:04:57,000 --> 00:04:59,000
Nothing is different then.

95
00:04:59,000 --> 00:05:03,000
Uh, we are going to take this entire data and we are going to scale it also.

96
00:05:03,000 --> 00:05:03,000
Okay.

97
00:05:03,000 --> 00:05:05,000
So here I'm going to probably go ahead and scale it.

98
00:05:05,000 --> 00:05:06,000
Okay.

99
00:05:06,000 --> 00:05:08,000
Then uh let's go ahead and do the churn.

100
00:05:08,000 --> 00:05:11,000
And with respect to the churn, I will just go ahead and write like this.

101
00:05:11,000 --> 00:05:17,000
If prediction churn, whatever prediction probability I'll get, I will just go and compare and say,

102
00:05:17,000 --> 00:05:22,000
hey, if this is greater than 0.5, I'll go ahead and write it in my Streamlit app.

103
00:05:22,000 --> 00:05:26,000
Otherwise I'll go it over here and say that, hey, it is not likely to churn, okay.

104
00:05:27,000 --> 00:05:28,000
So yes, this was it.

105
00:05:28,000 --> 00:05:32,000
I think, uh, everything was discussed already in the prediction dot ipynb file.

106
00:05:32,000 --> 00:05:34,000
So let me quickly go ahead and run it.

107
00:05:34,000 --> 00:05:35,000
Okay.

108
00:05:35,000 --> 00:05:41,000
So now this is the first time in order to run a Streamlit file, I'll just go ahead and write Streamlit

109
00:05:41,000 --> 00:05:42,000
run.

110
00:05:42,000 --> 00:05:43,000
App.py.

111
00:05:45,000 --> 00:05:45,000
Okay.

112
00:05:45,000 --> 00:05:46,000
Streamlit.

113
00:05:46,000 --> 00:05:47,000
Streamlit.

114
00:05:47,000 --> 00:05:48,000
Okay.

115
00:05:48,000 --> 00:05:49,000
Streamlit.

116
00:05:50,000 --> 00:05:55,000
So once I execute it, I will just say allow access and let's load it.

117
00:05:55,000 --> 00:05:56,000
So my file is getting loaded.

118
00:05:56,000 --> 00:05:57,000
Let's see.

119
00:05:57,000 --> 00:06:00,000
I should not be getting any error now.

120
00:06:00,000 --> 00:06:03,000
Right now here you can see the customer is not likely to churn.

121
00:06:03,000 --> 00:06:04,000
It is coming up over here.

122
00:06:05,000 --> 00:06:07,000
Let me print this particular value also over here.

123
00:06:07,000 --> 00:06:07,000
Right.

124
00:06:07,000 --> 00:06:09,000
What probability we are getting.

125
00:06:09,000 --> 00:06:12,000
So I will say hey go ahead and just print this.

126
00:06:12,000 --> 00:06:15,000
So tell here what I will do.

127
00:06:15,000 --> 00:06:22,000
I will just go ahead once I get the probability right I'm just going to go ahead and print it over here.

128
00:06:23,000 --> 00:06:29,000
So now let's go ahead and see it and let's reload it or okay.

129
00:06:29,000 --> 00:06:32,000
So here you can see churn probability is zero zero.

130
00:06:32,000 --> 00:06:35,000
So if I keep on increasing age is this increasing.

131
00:06:35,000 --> 00:06:37,000
See churn probability is increasing.

132
00:06:37,000 --> 00:06:40,000
Now you can add up any values you want to select Germany.

133
00:06:40,000 --> 00:06:41,000
Go ahead and select it.

134
00:06:41,000 --> 00:06:43,000
Add any balance like 10,000.

135
00:06:43,000 --> 00:06:44,000
Go ahead and add it.

136
00:06:44,000 --> 00:06:46,000
Here you can see churn probability automatically.

137
00:06:46,000 --> 00:06:52,000
The calculation will happen if I go ahead and add one credit card one active member.

138
00:06:52,000 --> 00:06:54,000
So see this value is also decreasing.

139
00:06:54,000 --> 00:07:00,000
So on the runway it is probably predicting my model is entirely predicting it right now.

140
00:07:00,000 --> 00:07:05,000
Uh, this was a very simple end to end project where I've used customer churn prediction.

141
00:07:05,000 --> 00:07:10,000
And uh, what you can do is that you can select different, different values and do the prediction automatically.

142
00:07:10,000 --> 00:07:12,000
This will do the prediction.

143
00:07:12,000 --> 00:07:15,000
Now quickly I will go ahead and open my GitHub okay.

144
00:07:16,000 --> 00:07:21,000
And uh with respect to GitHub I have to probably go and see the deployment, right?

145
00:07:21,000 --> 00:07:24,000
So what I'm actually going to do is that first of all, I'll go ahead and check in the code.

146
00:07:24,000 --> 00:07:27,000
Uh, you know how to do the check in with respect to the code.

147
00:07:27,000 --> 00:07:29,000
You can also use git init.

148
00:07:29,000 --> 00:07:34,000
But uh, this project, uh, I will just try to quickly upload it in my GitHub repository.

149
00:07:34,000 --> 00:07:36,000
So I'll just go ahead and create my GitHub repository.

150
00:07:36,000 --> 00:07:40,000
Let's say I will go ahead and write an classification okay.

151
00:07:40,000 --> 00:07:41,000
Churn.

152
00:07:41,000 --> 00:07:46,000
And here uh I will just go ahead and create this.

153
00:07:46,000 --> 00:07:48,000
Add a Readme file general Public license.

154
00:07:48,000 --> 00:07:50,000
Go ahead and create a repository okay.

155
00:07:51,000 --> 00:07:56,000
So once this is created now in my next step what I will do I will go ahead and upload all the code over

156
00:07:56,000 --> 00:07:56,000
here.

157
00:07:56,000 --> 00:08:00,000
And then we will go ahead and see how we will be doing the deployment.

158
00:08:00,000 --> 00:08:02,000
This into a Streamlit app.

159
00:08:02,000 --> 00:08:06,000
Okay Streamlit cloud, that is what we are going to see in the next video.

160
00:08:06,000 --> 00:08:08,000
So I hope you like this particular video.

161
00:08:08,000 --> 00:08:09,000
I'll see you in the next video.

162
00:08:09,000 --> 00:08:09,000
Thank you.

