Hi. In this video we will learn about the first hyper parameter tuning method.
Uh, grid search,
grid search is a very easy to understand method. Basically,
you just put into a list, uh,
multiple values for each parameter we want to test,
and you evaluate your model for each combination of this parameter,
and you choose, uh, the model, uh, where you get the best result. Uh,
grid search and also other methods of hyper parameter tuning is used in
combination with cross validation. For example,
let's try, uh, the X GB classifier and let's test, uh,
three parameters, maximum depth of the trees,
a number of estimators and the learning grade.
Then we use, uh, grid search, cross validation class from sticky learn,
where we set the estimator, which, uh, parameters we want to optimize.
Uh, then the parameter grid we want to test
scoring metric to use.
We can also specify number of course to use.
Minus cut minus one stands for all CPUs.
Number of faults in cross validation verbal C level.
Uh, the higher the value,
the more information about the model training will be printed.
We also want to see the model performance on training data.
And then we just call the feed method on the instantiated grid search CV object.
We see here that we have, uh,
96 combinations of these parameters. And with, uh,
threefold cross validation, we basically, uh, train altogether,
uh, 288 models.
After the feed method, the hyper parameter search is, uh, complete.
We can check it result exploring the, uh,
CV results attribute. Uh,
we see here a lot of detailed information about how much time the model training
took, about the performance of the model. In each, uh,
parameter combination on trained and test set.
We also see the exact values of the parameters and so on.
We can also check, uh, what was the best score. Uh,
we can check also the best parameters, uh, and also we can get, uh,
the best estimator objects, uh, which we can then evaluate on the test data.
And we see it has accuracy of 95%
in grid search. Uh, we can also use the pipeline, not only the main model.
Uh, for example here, uh,
we have a simple pipeline consisting of normalization with standard scaler
and a model,
our parameter grid may consist of the same parameters as before.
Plus, we can explore what effect on the performance of the vol pipeline.
We'll have, uh, different normalization methods like standard scaler,
robust scaler, normalizer,
and without using any normalization method at all.
Instead of testing, uh, different scaling methods, uh, we could, for example,
test only one normalization method, like the standard scaler and its parameters.
Or we can test for multiple main models.
We could add here to the parameter grid logistic regression,
separate vector machines like G B M or other type of model.
Let's check what is the best pipeline we see, uh,
that with the standard scaler and with these parameters of the main model.
In our next video, we will learn more about a randomized search.