All in all our previous sessions, we have done lots of analysis, lots of cleaning, lots of techniques
for future importance, feature encoding and much, much more so in this session.
This is the session that you all guys are waiting for.
And in this session, we are going to apply our machine learning algorithm on data because up to a greater
extent, our data is ready to apply your machine learning algorithm on your data.
So let's open your assignment.
What you have to do.
The very first statement is you have to apply an algorithm after it.
You have to cross validate your model as well.
So for this, what we have to do very first, you have to split your data in the form of training as
well as your testing, because once you have trained data, you can train your model.
Once you have test data and you can check what exactly is the accuracy of your model.
So for this, I'm just going to say from my Escalon module, I have something which is exactly my model
and of course, selection.
And from this I have to import something known as train on a score test and a score split just to execute
it.
Now, what we have to do is you have to simply call this class.
And in this, if I am going to pass shift plus tab, you will check all these parameters over here,
Taci train side Sefl, Stratify splitting and all these different, different things.
And what will it and it will me this exchange test y train and whitelist.
So here I'm just going to say I have to pass my X and Y and after it I have to pass my test side.
So I'm going to say test on the cost side, let's say nothing or zero point two five.
It means you're twenty five percent of data will be considered as a test data and the rest will be you're
carrying it out.
So I'm just going to say it will be done with all these parameters.
So I'm just going to execute this cell and let me pass one more parameter, which is exactly random
underscore estate, which is exactly, I'm going to say random on a score instead and just a standard
zero and just execute this.
Now, what we have to do, we have to simply apply our machine learning algorithm on our data.
So let's say we are just going to apply logistic regression because this is exactly of a classification
algorithm.
So here we have to apply logistic regression on our data.
And if you guys are not that much of it about what exactly the velocity regression.
So I have explained the mathematics intuition behind this logistic regression.
Just check out my previous videos and you will be able to find what exactly is and mathematics, how
this logistic regression exactly works in your machine learning.
So very first, I have to aim for something which is exactly my own site.
Gatland got linear underscore model.
I have to import my lines to progression.
So I'm just going to say just execute the cell.
Now, what we have to do, we have to initialize this logistic regression.
So I'm going to say logistic regression just in size it let's say here you have some custom parameters
here.
You can simply say you have dozens of parameters over here.
So let me iStore its object as, let's say, Lavarack, just execute the cell.
Now, what we have to do using this object, I'm just going to call my fit over there and what I have
to fit I have to fit my training data, which is exactly X on this score and basically my Y on the screen
because I have a screen model.
That's it.
And just execute the set.
It will take a while and it will return as my amazing logistic regression model.
You will see all these custom parameters over here.
What is the parameter for the class.
Wait, what is it all your different different parameters?
What exactly is your regularization technique, which is exactly all these things.
Now what you have to do, you have to simply do prediction on your testing data.
So I'm just going to say LaGreca not predict what I have to predict.
I have to predict on my X on a test after doing prediction, let's say I have restored my prediction
X, I'm going to say it is nothing but my yna school grad.
It just executed.
And if I have to paint this so just execute this, sell all this stuff gets executed over it, you will
see all the prediction in the form of add it over here to wherever it is one.
It means your book is going to cancel and wherever it is zero, it means your booking is not going to
cancel.
That's why it is exactly what classification use is now.
What we have to do, we just need what exactly is a confusing matrix of my logistic regression model.
So for this, I'm just going to say from this side, Gittleman, I.
Playing board, something which is exactly my metrics, and from these metrics, I have to import something
which is my confusion metrics.
Now what we have to do from this confusion call metrics, I have to pass my ad, which is exactly my
lie and test.
The second is exactly my why on this score, Brad just executed.
And this is your amazing metrics.
You will see these are exactly the correct prediction as well as these are exactly correct predictions
and these are your not correct predictions.
So let's see.
I just need to hear what exactly the accuracy of my model so far is.
What I'm going to do.
I'm just going to say from this cyclone dot matrix, I have to import something known as which is exactly
accuracy score.
Now, what I have to do, I'm just going to say accuracy score.
And in this accuracy score, I have to pass.
Why test after it?
I have to pass a wide spread and just execute the cell.
You will see your Lustick regression model has somewhere close to seventy two percent accuracy.
So if you guys are thinking this is the exact accuracy of my last two regression model.
So no, you all are wrong.
This is not that accuracy which is related to velocity regression model.
It means you have to come across with your right accuracy so how you can achieve that exact accuracy.
So in such scenarios, you have to cross validate your model.
So let me show you a thing.
If I'm going to let's say if I'm going to change this random sandwiches and its value as, let's say,
42.
So if I'm going to execute again, execute again and let me just execute again, let me show you a thing.
And if again, I'm going to execute it and I'll get executed and let me show you what exactly is accuracy
after playing with my randomness Christian parameter.
And again, I'm going to execute the search.
Now you will see your accuracy from seventy one gets jump to seventy five.
So you will thinking yeah.
You automatical going over here.
So that's the scenario where you have to cross my little model.
So whenever you will get your accuracy without consolidating your model, you have to always say I have
achieved accuracy within this, this range.
It means now to get the exact accuracy you have to cross, validate your model for this.
I'm just going to say from this side, Keadilan, I have something known as model selection.
So I'm going to say model unaskable selection.
And from this I have to import something known as cross on, as Corvalan is called, just execute the
cell.
Now, what we have to do that is first I have to initialize it and just shift crosstab.
You will see.
What exactly is your estimate?
What is the X?
What is it Y and what is your CV parameter?
So if you guys doesn't know what exactly this cross validation, just check out my previous videos.
I have explained it and everything.
Go there.
So here, if you will pass through Gustav, you will get all these parameters over here.
Now you have to set all these stuff to my estimate.
What exactly Lorac and my X was X, my life was like, let's say I have to assign my cross-validation.
It goes to ten.
And if let's say whatever it will on me, let's say I'm just going to execute the set.
Now, you will see over here with respect to X, Y and the C.V parameter, you have this, this is called
selectees told somewhere else.
Let's say I'm just going to store it in score and let me just execute it again.
Now, what we have to do to achieve your exact score, you guys can just call me an order that simple.
You have to just execute the cell.
And now you will see over here it has accuracy of somewhere close to 70 percent.
It means you're 70 percent predictions are going to.
Correct.
So that's all about the session of the session.
Very much how exactly I have implemented my machine learning algorithm on data, then how I have crossed
validate my model as well, because this is your most important aspect of the machine learning approach.
So I hope you love this session and this session will be very helpful for you.
Thank you.
Have a nice day.
Keep learning.
Keep growing.
Keep practicing.