GridSearchCV

I'm reviewing the Trading with Machine Learning Regression and would like to understand more about the following command:



reg = GridSearchCV(pipeline, parameters, cv=5, verbose = 5)



When I turn on verbose it appears that this command actually does something.  Originally it was my impression that this was still just setting the stage for running the prediction and that the "reg.fit" command that follows did all the work.  Could someone please explain what the GridSearchCV command is doing at this point?  Thanks,

J

 

Hey John,

Grid Search is the process of performing hyperparameter tuning in order to determine the optimal values for a given model.



We use the GridSearchCV function to evaluate the model for every combination passed using the Cross-Validation method. The function then returns the accuracy/loss for every combination of the hyperparameters and we can then choose the one with the best performance.



The parameters provided to the GridSearchCV function are as follows:

  • estimator: Here you pass the model for which you want to check the hyperparameters.
  • params_grid: This is the dictionary object that holds the hyperparameters that you want to try out.
  • cv: Here you can specify the number of cross-validation you want to try for each selected set of hyperparameters. The default is 5-fold cross validation.
  • verbose: Used to specify the amount of text output that you want to be displayed while you fit the data to GridSearchCV. The example shown here will help you understand 'verbose' better.
If you are interested in learning more about the GridSearchCV library function, do consider exploring the official documentation page of the same.

I hope this was helpful.