1. Learn
  2. /
  3. Courses
  4. /
  5. Hyperparameter Tuning in Python

Connected

Exercise

The RandomizedSearchCV Object

Just like the GridSearchCV library from Scikit Learn, RandomizedSearchCV provides many useful features to assist with efficiently undertaking a random search. You're going to create a RandomizedSearchCV object, making the small adjustment needed from the GridSearchCV object.

The desired options are:

  • A default Gradient Boosting Classifier Estimator
  • 5-fold cross validation
  • Use accuracy to score the models
  • Use 4 cores for processing in parallel
  • Ensure you refit the best model and return training scores
  • Randomly sample 10 models

The hyperparameter grid should be for learning_rate (150 values between 0.1 and 2) and min_samples_leaf (all values between and including 20 and 64).

You will have available X_train & y_train datasets.

Instructions

100 XP
  • Create a parameter grid as specified in the context above.
  • Create a RandomizedSearchCV object as outlined in the context above.
  • Fit the RandomizedSearchCV object to the training data.
  • Print the values chosen by the modeling process for both hyperparameters.