Head on before going ahead in the session.
Let's have a glance on what we have done in all of our previous precision from initial two till now.
So basically from retired bought today to cleaning, lots with analysis, lots of possibly lots of techniques
for feature encoding, outline reduction, this feature selection as well that we have done automate
our all the processes that we have done for our model.
And then we check what exactly the accuracy of different different algorithm.
And then we have played with all these different different kinds of algorithms, like getting linear
regression.
This isn't really random for us.
And arrest is this one code.
And you can play with multiple regression and whatever you want.
So in this session, we have this assignment in which I have a problem, a statement in which I have
to hyper to my model to why there is a need of performing hyper parameter tuning and why you have to
apply on your data, why you have to apply on your machine learning algorithm.
So let's see if I'm going to press shift plus tab over here.
You will see it with respect to this entry.
These are exactly my all the default parameters that are selected by your decision team, but there
is not any guarantee with respect to my Justis, these are my best parameters.
So what we are going to do, we are basically going to use our hyper parameter tuning approach.
And in this we have randomizer, TV, great TV ad, different cross-validation approach.
What they will do, they will basically return us best parameters for our model so that my training
will happen in the best of it and it will exactly return as best escort.
That's what all these cross-validation that are exactly my high for tuning approach.
That's what this will do.
So very close to what we are going to do.
So basically there are two approaches that you can go ahead with.
The first one is a randomized search approach randomizer.
Such the second one is you'll see there is still some advanced approaches like Jandakot algorithm,
some of do not algorithms.
So they are basically very advanced.
So we are basically going to deal with grid search or readymades says it's all up to you.
So basically, we are going to deal with a randomized search.
So what I'm going to do very first, I have to import it.
Let's say I'm going to say from this cyclone dot model selection, you have to ready for this one that
I'm going to import my randomizer CV.
So if I'm going to, let's say, initialize it so you will see over here, it wasn't just going to copy,
just paste and just to you will see all these different different parameters.
What exactly is estimates are, which is nothing but object of your machine learning algorithm that
I have parum distribution in which I have to pass whatever parameters of my machine learning algorithm.
I have to pass that parameters in the form of dictionary.
So this is not exactly a data in the form of keyword, because then I have this ad in the what are the
number of applications I want, what is encoding parameters, all these different different languages?
I have to play with it as well.
So what I'm going to do over here, say if I'm going to let's say, oh, let's say random forest regression,
and if you will pass shift crosstab, you will see all these different different parameters in case
of random forest.
We have all these parameters.
No, this isn't exactly my NIST meters.
What is your criterion?
Which is exactly what MFC what is a master depth of field.
This is what I mean.
Most samples is what are your minimum sample sleeve and all these different different parameters.
So you have to play with all these parameters to hypotenuse model.
So what I'm going to do, if you will, have these, are all these different, different parameters.
So let's say what I'm going to do, I'm basically going to create a random grade as dictionary.
So I to be ready.
And here basically I'm going to define my all the parameters of random forest in the form of dictionary.
So here I'm going to say the very first parameter is exactly my an estimate.
So my end estimate is nothing, but number of result is exactly one.
So here I'm going to say so I will receive the value of this key from here.
So here I'm going to say four X in, so I'm just going to to it.
As for X in.
Umpired got lost, so here you have a function, this land space, and here I'm going to say, if you
will pass shiftless tab, you will see from there you have to start.
And at what point you have to stop a number of things that you want or number of items that you want
in your party or list or whatever you can don't ask.
So here I'm going to say here mine is DOT is nothing but my hundred and stop.
I'm going to say I have to stop it at my dual handed decision and how many total estimates I want here.
I'm going to say I just need, let's say six.
And after what I have to do, I have to let's say I'm going to convert it into some Intisar so far that
I can call this.
So this is exactly nothing but a code of lisp comprehension.
So if you're not much comfortable with this list comprehension code, you guys can follow my basics
of Python goes in which I have got all these basics of Python in just approx in an hour.
So now what we have to do.
So here I have to mention my and and a score estimate.
And it is exactly that list that you have to mention over here.
So here I would say and an estimate was after that, what we have to do, we have to also set what are
my maximum features.
So here I'm going to say, Max, on the spot features of all these features, all about number of features
to consider at every split of the season.
So maximum on its core features.
And here I am going to accept fill it with my list for him to see.
The very first one is nothing but my auto.
The second one is nothing but my squatty.
After what we have to do, we have to deal with our max on this code that features, which is exactly
maximum number of levels in our decision.
So here I am going to say Max underscored that and it is nothing but here I'm going to something mentionable
the maximum that is nothing, but it is just a list.
So here I'm going to say let's say I'm just going to copy this entire code and I have to do some modifications
over here.
So just do copy paste.
And this time, let's say I have to basically start from five and till 30 I have to move.
And I'd say I just want four values.
And in this max depth, you have all these things.
Then you have to assign this value, which is exactly new, Max, on this contempt after it.
What you have to do, except I still need some more data, some more parameters.
So the last one that you need is exactly what I mean, unless all samples and a score split.
So what this feature is all about, minimum number of speeds required to split node here.
I'm going to say you guys can consider these random values that a five, 10, 15 and 100.
So I'm going to consider these values from my own experience, working machine learning domain.
So after it, what we have to do, we have to just execute it as well as we have to also execute this
dictionary, which is exactly you're right on the school grid.
Now, if I'm going to print this dictionary, which is exactly in this Cinematical grade use, this
is exactly the dictionary that you have to parse to randomizer see in your bottom on the score distribution
parameter so that if I have to initialize man and my CV and here in this estimate, or I'm going to
say in this estimate, you have to parse object of your random forest very first.
So here I'm going to say let's say I'm going to create an object of random forest very first.
So here I'm going to say from this ascalon, from this ascalon dot in Sambell, just best Dabb, I have
to import my random forest.
So I'm just going to import this.
And if you stamp this is exactly that, just execute it.
Now, what you have to do, you have to simply initialize this.
I'm going to say let's say it is nothing, but it is mine that they are e.g. score R.F. whatever you
want to name it, it's all up to you, just as you did.
Now what you have to do in this estimate, you have to parse its object some way to say regression and
a school or you are a school area.
And in the very second parameter you have to set you have to set this random grade.
So here I am going to say my random great parameter and let's see.
And we will say Mycenae.
Is my cross validation equal to three by default?
It is a swipe and after in my verbose parameter, so is basically to show your whatever activity is
happening across your cell once you will, as you said.
So what was it goes to do?
And after that, I'm going to set mine and in good jobs parameter as let's say, minus one.
So whenever you are going to parse this minus one, it means it will use all the course.
It means it will use all the resources of.
Let's say I want to store it in some variables here.
I would say that one is random, so just executed.
Now what we have to do, we have to simplify it, our data.
So I'm going to say out of an it's got random, not fit.
So what we have to fit, we have to fit basically X on the screen and definitely Y and just execute
it.
It will take some couple of seconds.
You will see all these things come across.
So sad because you have said your variables equals two.
So it will take a couple of seconds depending upon what processor you are using, depending upon what
specifications of the system.
Now you will see all your stuff gets executed and it has taken that much time in my system having my
own specification for in your case, it will take definitely depending upon what it is in your system,
how you will see.
These are all the parameters written by my cross-validation, written by my randomizer cross-validation
software it what we are going to do, let's say I'm going to check what are my best parameters.
So here I'm going to say right part this for random dot best underscore firearms to just have the order.
You'll see these are my best parameters selected by my cross-validation validation.
So now what I'm going to do very first, I have to do a prediction.
So now I'm going to say this on this random dot product, because you have to predict on your X underscored
test data supporting prediction.
I'm going to store it in, let's say, prediction and let's say if I'm going to execute it and if this
time you are going to check what is exactly distribution between your actual data, minus whatever prediction
you have done or what did.
So I'm going to say this is nothing, but this is this type of distribution that I have achieved using
my randomized search.
And if you are going to check what exactly is accuracy after doing this, all these highfaluting for
this, I'm going to say metrics dot are to underscore a square, and here you have to pass.
What is the actual data and what exactly is a prediction?
Just executer you will see now you have in case of random forest, you have somewhere approx.
Eighty three percent accuracy.
But before when you use random forest, you can observe you have some tools to 80 percent accuracy that
are bovver of your model highfaluting.
Whenever you are going to work on real world projects, you have to always hyper tuned model.
You have to always cross validation model.
That's a power of your model.
It will definitely increase your accuracy.
Let's say I have to say it.
Let's say I have to dump this model, this best model that I have created over here.
It's very first what I'm going to do.
I have to open some flat in which I can dump this.
For this, I'm going to say where I have to open it.
So I'm just going to copy this part.
Just going to paste over there and here.
I'm going to say this time, my model name is, let's say AALDEF on a random dot Beaky.
And then I have to say, in what model I have to open this file.
So here I would say in writable.
So just execute.
And now what we have to do, we have to use this pikul dot dump.
And here I have to say I have to dump this order from the random into my file.
So just execute it.
And now you will see over here, here is exactly your model that is right now creating over here.
Let's say we have to do prediction using that model, using that model that I have created over here.
So what we have to do at first, we have to load this model that we have done.
So now I'm going to say very first, I'm very first.
I'm going to say what I have to open very first.
So let's say I'm just.
Going to copy this, but let's see, so I'm just going to go up with is just going to Pastoria, let's
say I have to load my previous model that I have created, which is exactly my model dot beacon.
And here I have to say to my read in binary mode, because I have to read that plan after what I have
to do, I'm going to save it in the fly.
And after it I have to basically load my models here.
I would say bikal dot load.
And here I have to let's say I'm going to store it, let's say in model.
And after I left it, I would say I have to load this model.
So once you were executed, you will see this is that model of random forest class that you have imported
earlier.
Similarly, you can load this crossover little model that you have dump over here.
Let's say I have to do prediction using this model.
So I'm going to say model for it.
Let's say I am going to say model dot product and you have to just use of credit function and on what
data you have to predict to what I am going to do very first, you have to store this model somewhere.
So let's say I'm with the store again.
Let's say for this or random forest, it's all up to you.
And after it, what we have to do using this forest, you have to call a Braddick function.
And here you have to mention, let's say, X test.
And if you will execute you, you'll see over here you have all your predictions with respect to this
X test data.
That's it.
I have to store these predictions.
We are somewhere as, let's say, predictions doom.
So just executed.
All the prediction is exactly over here.
I'd say I have to check the accuracy as well.
So here I would say Kranks dot to describe breast.
And here you have to mention what exactly is your exact data and after that, what is your predictions
exactly.
And predictions do so just execute and you will see this is the previous accuracy that you have achieved
earlier and similarly you can perform all these is similarly for your cross village model.
So in such scenarios, you will definitely get somewhere approx, 80 percent accuracy that you have
achieved over here.
So that's what I'm trying to show you.
So let's see if you have some new data.
You have to just pass that new data over here and you will get your accuracy.
So that's all about this project.
Hopefully you'll love this project very much and try to explore from your own site as much as you can.
So thank you, guys.
Have a nice day.
Keep learning.
Keep growing, keep motivating.