So, guys, uh, till here.
Now, we have seen each and every thing.
We have trained our entire an, uh, artificial neural network.
We got the loss.
The loss was also very less.
We saw the loss in our TensorBoard, uh, visualized the entire diagram.
We saw various parameters.
Then we went ahead and did the prediction.
We saved all the pickle file.
We loaded all the pickle file.
And, you know, we could also see the prediction was also happening.
Everything.
We did it.
Now it's time that we create one app.py file.
And this is what I'm going to specifically use as my Streamlit web app.
I'm going to probably create an end to end web app, where I will be able to give the inputs and do
the prediction from there.
So let's go ahead and here is my app.py.
So first of all I need to import all the libraries that I really require.
So one is streamlit as st numpy tensorflow sklearn.preprocessing.
I'm going to use standard scalar labelencoder onehotencoder.
So whatever things we specifically did in the prediction dot ipynb file, we'll be doing it okay.
So the first step is loading the loading the trained model.
So I'll go ahead and write tf dot Keras.models dot load underscore model.
And I will be giving my model dot h5 file name.
Um, then, uh, what we will do is that we will go ahead and load all our encoder scaler.
Um, you know, one hot encoder, all the files itself.
So here you have one hot encoder G0 dot pickle file.
And I'm encoding this.
So here you can see one hot encoder underscore geo dot pickle I am loading this in the read byte mode.
Then I have this pickle dot load.
Then I'm also loading this scaler.
Right.
So all this pickle is specifically getting loaded right now.
Let's quickly start with the Streamlit app.
So here I'm going to use a Streamlit app because I don't have to worry about HTML and all.
So that is the reason I'm using this.
So I'll go ahead and write this t dot title.
Let me go ahead and write customer churn prediction okay.
So customer churn prediction I'm going to use over here.
Customer churn prediction.
So this will basically be my title of the Streamlit app.
Now see you know that how many types of inputs you are specifically giving you are giving geography
gender age, balance, credit score, estimated salary, tenure, number of products has credit card
or number of uh uh, number of products already mentioned.
Right.
Is active member.
Also these are some of the features.
So based on these features I need to provide my input from the Streamlit web page.
So for this we will go ahead and create all these inputs.
So for geography I'll be using uh drop down uh which will be specifically using all the categories.
So categories of zero whichever is the categories of zero.
By default it will get loaded.
Over here it can be zero, one, two or any name that we are going to give over here.
Then you have this dot select box, whatever values or with respect to the classes that I have I'm actually
able to get it over here.
Um, then uh you'll also be able to see HD dot slider.
I'm using a slider for age.
I'm using a input for balance credit score, HD underscore number, credit score.
Estimated salary is again number underscore input.
Then for tenure again I'm using a three dot slider between 0 to 10.
Uh, I'm also using a slider for number of products and similarly has credit card and is active number.
Okay.
So this is what is the input data I will be giving from my user input.
Then I will prepare this input data by taking it in some kind of dictionary.
Right.
So we will go ahead and prepare this dictionary.
So here I have my credit score I'll take this data gender I'm going to use this labelencoder gender
and use uh transformer uh transform and probably get the zeroth value.
Then age is here.
Ten year is here, balance is here, number is here.
And each and everything, all the informations are specifically here.
Okay.
Now, uh, one more information that is missing.
Uh, is basically our, um, one hot encoder, which is my geographic column.
So for geography I will try to encode it in a different way, like how I did it in my prediction dot
ipynb file.
So I will just go ahead and encode this geography.
So here is my geo encoded.
I'll take this geography value which is from here.
Write this geography value.
I will take this in the form of list.
I'll convert this into an array by using one hot encoder dot underscore geo dot transform.
Then I'm converting back into a data frame by taking the feature out feature names over here.
Right.
So, uh, this is what I am actually specifically getting for all my values.
Now I will combine this one hot encoded with my input data.
Right.
So for that again we'll go ahead and write pd dot contact concat I'm saying input data dot reset index
drop is equal to true.
Then take the geo underscore coded and encoded underscore df with access is equal to one.
Same thing what we did in the prediction dot ipynb file.
Right.
Nothing is different then.
Uh, we are going to take this entire data and we are going to scale it also.
Okay.
So here I'm going to probably go ahead and scale it.
Okay.
Then uh let's go ahead and do the churn.
And with respect to the churn, I will just go ahead and write like this.
If prediction churn, whatever prediction probability I'll get, I will just go and compare and say,
hey, if this is greater than 0.5, I'll go ahead and write it in my Streamlit app.
Otherwise I'll go it over here and say that, hey, it is not likely to churn, okay.
So yes, this was it.
I think, uh, everything was discussed already in the prediction dot ipynb file.
So let me quickly go ahead and run it.
Okay.
So now this is the first time in order to run a Streamlit file, I'll just go ahead and write Streamlit
run.
App.py.
Okay.
Streamlit.
Okay.
Streamlit.
So once I execute it, I will just say allow access and let's load it.
So my file is getting loaded.
Let's see.
I should not be getting any error now.
Right now here you can see the customer is not likely to churn.
It is coming up over here.
Let me print this particular value also over here.
Right.
What probability we are getting.
So I will say hey go ahead and just print this.
So tell here what I will do.
I will just go ahead once I get the probability right I'm just going to go ahead and print it over here.
So now let's go ahead and see it and let's reload it or okay.
So here you can see churn probability is zero zero.
So if I keep on increasing age is this increasing.
See churn probability is increasing.
Now you can add up any values you want to select Germany.
Go ahead and select it.
Add any balance like 10,000.
Go ahead and add it.
Here you can see churn probability automatically.
The calculation will happen if I go ahead and add one credit card one active member.
So see this value is also decreasing.
So on the runway it is probably predicting my model is entirely predicting it right now.
Uh, this was a very simple end to end project where I've used customer churn prediction.
And uh, what you can do is that you can select different, different values and do the prediction automatically.
This will do the prediction.
Now quickly I will go ahead and open my GitHub okay.
And uh with respect to GitHub I have to probably go and see the deployment, right?
So what I'm actually going to do is that first of all, I'll go ahead and check in the code.
Uh, you know how to do the check in with respect to the code.
You can also use git init.
But uh, this project, uh, I will just try to quickly upload it in my GitHub repository.
So I'll just go ahead and create my GitHub repository.
Let's say I will go ahead and write an classification okay.
Churn.
And here uh I will just go ahead and create this.
Add a Readme file general Public license.
Go ahead and create a repository okay.
So once this is created now in my next step what I will do I will go ahead and upload all the code over
here.
And then we will go ahead and see how we will be doing the deployment.
This into a Streamlit app.
Okay Streamlit cloud, that is what we are going to see in the next video.
So I hope you like this particular video.
I'll see you in the next video.
Thank you.