So in the last video we created over Libya, as we are more than for sequel to zero point zero one.
But how to ensure that this is the best sea which we can choose for our linear model?
We can provide any value of sea and for each value of sea, we will get a separate model and the accuracy
escort will be different for all such models.
So one way is to manually change this sea so I can run the same model with sequel to one with sea equal
to zero point one and with sequel two hundred and manually compare the accuracy results for all such
models.
This is a lengthy process.
To overcome this lengthy process, we can use grid search option of a scale on here.
We can provide.
Different values of SI.
And Biton will automatically run our model with all these values of see.
And later on, we can use the best model out of this given models.
Could do this.
We have to use grid search c.v.
So first we have to import grid search seewhy from Escalon modern selection.
Now, next step is to create a dictionary in which you have to mention the name of your hyper parameter
as a key.
And the value it will be taking as a values of your dictionary.
Here, since I want to change values of SI.
I will provide see as a key and then these are the values.
I am passing this values in the form of poll.
You can see I have selected values from zero point zero zero one to tosing.
So I will run my model for all these 13 values of see.
If I want to change and the other hyper parameter, I can just broyd another key value pair.
Now, we have created a weather parameter dictionary.
The method of using grid search is almost similar to that of training a model.
There is one additional step.
First, we need to clear the model that we are going to use in grid search.
So suppose if we are using support vector classification, we have to create an object for support vector
classification, a field using linear regression.
We have to create an object for linear regression.
If we are using support vector regression, we have to create an object for support vector regression.
So first, the surplus to create that object.
Then just like any other model training, we have to provide parameters and grid search.
The first parameter is the word model.
Then the second parameter is the list of parameters that we have already created.
Note that this should be in the form of a dictionary with the parameters of your model as scheiße and
their values as values.
Then there are a few other parameters.
The next parameter is and jobs.
This should be equal to minus one.
This is used to maximize the performance of your laptop or machine.
So minus one means your computer or your system will use all the processing power for training this
model.
Then the next parameter is CV.
CV is for cross validation.
So if you don't know what cross-validation is, Biton will create in our model.
All this will lose of C.
And then it will automatically use a part of of, uh, training data to get their test result and find
out the accuracy scored on this many values of parameter.
So CV is ten here.
You can change this number if you want.
Then verbals is equal to one.
This represents the amount of message we are going to get.
While we are training or model.
So you saw that we received messages in our output.
So a few give.
What was it?
Well, the one you will get some message while you're cleaning your data.
And the next parameter is scoring.
Here we want to use accuracy scores of this models.
Therefore, we are using scoring well to accuracy.
Then the next step is just like any other model.
We will fit this grid search object using our test, Sandrine.
And after that, since we are training this many models, we can pick the best model and then predict
the values of my variable.
So let's first import the grid search.
Cleared this paramedic study.
Cleared this VLF, a solemn, linnear object.
You can see that we are just using as as we see with current liquidly, too linear.
And then.
We are creating a of grid search object.
If you want more details on the parameters.
You can open the documentation of Eskil and Grid Search.
You will get all the information there as well.
Then the next, the surplus to Fethullah data.
Remember to use standard X data instead of just X variable.
Now, you can see we are getting this kind of messages.
This is because we have used verbal sequel to one.
You can see we have provided turbin values of see, that's what we are getting, the message that we
are fitting then for we model for 13 candidates.
For you to send for cross-validation, equate to 10.
This may take some time.
You can see that we have fitted our models now grid search comes with different attributes.
The first attribute here is best underscored patterns.
This will give you the information of the best model.
Although this 13 models.
So if freed on this, we can get the parameter for which we are getting the best result.
So out of all this sea values, we are getting our best preserved at sea.
Well, two zero point five.
So you can see that there is no need to separately run.
You are more than for each value of sea.
You can just provide a single Padam dictionary and grid search, do random order for all the values
of sea that you have mentioned in badam parameter.
The next secretary butyrate is best under score, estimate estimated.
So with best underscore Perram, we were getting the parameter value corresponding to our best model,
that best center scored Sumita.
We will get our best model.
And here we are simply saving this, our best model, as Len, as we underscore to see Alef later on.
We will use this Lin as a swimmer, not to score CnF.
To predict the values of this.
Let's run this.
So now we have a what best model?
The model with sequel 2.5.
And this variable.
Now, let's find out the accuracy score.
Here we can radically use why test and instead of providing a separate credit variable, we can directly
use Daudt predict function here.
So let's run this.
The accuracy for our model is zero point five nine.
So this is the best accuracy which we can get out of this 13 values since our data is very less.
And we only have around 500 observations.
That's why he a good service is not making much sense.
And we may get accuracy score lower than our initial accuracy score.
So don't worry about that.
If you have large amount of data, grid search will definitely give you a better result as compared
to some random value of parameter.
That's so we use grid search in the next lecture, will green, a polynomial caramel SVM model.