In the last video, we saw how two men came in for a given medley of gay.
We trained our model for where to one and Capullo three.
We created two separate models for these two given values of care.
In this lecture, we will learn how to create a single model for multiple values of care.
We will use grid search feature of Ashkelon to do this.
First, the surface to import grid search c.v from Mordente Selection of Escalon.
Now, if you notice here, when we were running, came in for Gaikwad two, three and equal to one.
We were changing this and underscored neighbors barometer of gay.
To give multiple values of gay using grid search, we first need to create a dictionary of this parameter.
So I'm calling my variable as bedrooms and I'm creating a dictionary with my end neighborhood parameter
is taking value from one to 10.
This is just a list of all the numbers from one to 10.
And this list is in our dictionary with an underscore a neighbor as index.
Now, similar to our previous model, training process will first need to create an object of over classifier
and then retrain this object using over X and Y variables.
So here my object name is Underscore, Search, Underscore CV.
And I am using this grid search CV function to create this object.
The arguments here are first you need to give the classifier.
And second, you'll need to give their dictionary of all the parameters you want to change.
So my classifier is geared neighbors classifier.
Remember, we Uki neighbor classifier, vilely creating Gamin and my second argument here is bedrooms.
We created bedrooms, which is a dictionary containing and Nabor says index and a list of values from
one to 10 as its values.
So this grid search S.V. Object Contain came in classifier for all the 10 values of Gayed that time
giving in the bedrooms.
If I ran this.
My research object is ready now.
I will fight it using my X brain is scary version and the wide screen variable.
Now, I have created my more than.
To find out the best barometer out of this 10 given parameters, there are different attributes of grid
search c.v function.
The first attribute based.
Best Scott Bedrooms underscored.
This will give me the value of the best barometer out of the given parameters around this.
You can see the best barometer out of this 10 parameter is when the key is equal to seven.
Now, I know that the best value of K is seven out of this ten values.
The second attribute is best underscore, estimator, underscore.
So remember, we trained our model for ten values of key.
So we have ten different kanon models inside this grid search CV.
This best underscore estimate that will pick up the model, which is the best.
So here it contains the model with K equal to seven.
Now, I will directly copy this.
Best estimate there and to over another model, which I'm calling.
As optimize underscored underscore in.
So now my model with Gaikwad two seven is optimize skinning if you want.
You can create another classifier on your own with equal to seven, as we did with Gache with the one
and equal to three.
Now, if we want to credit to revive a loose rule using the word expressed values, we can directly
use the credit function with this optimise scannon.
So I am saving my predicted values environ.
The score tests underscore pride and I am using credit function of this optimized scannon renders them.
This.
Similar to the last time.
If we want to create confusion metrics, we just have to use confusion, underscore metrics.
And then the white test, that is the actual values and the period.
Good news.
You can see this is the confusion metrics.
You know, all the rules, labels and the column labels, the columns are credit card values and the
rules are actual values.
If we want to find out the accuracy score, which is 37 plus 22 divided by a hundred and two total Nemerov
observation will come out to be point five seven.
So remember, four key equal to one.
Our accuracy was one five three four.
Gateway two, three.
Again, our accuracy was one five three.
But for Gateway to seven, our accuracy is zero point five seven.
If you want, you can give another values for the UK here.
So if you if you want venti or 30, you can mention all these values in your dictionary.
And then you can train your model on all these values using a certain CVO option.
That so you run, okay?
And then for multiple values of gay without duplicating your codes multiple times.