Implementing Random Search
Implementing Random Search (see Chapter 3, Exploring Exhaustive Search) in sklearn
is very similar to implementing Grid Search. The main difference is that we have to provide the number of trials or iterations since Random Search will not try all of the possible combinations in the hyperparameter space. Additionally, we have to provide the accompanying distribution for each of the hyperparameters when defining the search space. In sklearn
, Random Search is implemented in the RandomizedSearchCV
class.
To understand how we can implement Random Search in sklearn
, let’s use the same example from the Implementing Grid Search section. Let’s directly try using all of the features available in the dataset. All of the pipeline creation processes are exactly the same, so we will directly jump into the process of how to define the hyperparameter space and the RandomizedSearchCV
class. The following code shows you how to define the accompanying distribution...