Session Ready
Exercise

Automating Hyperparameter Choice

Finding the best hyperparameter of interest without writing hundreds of lines of code for hundreds of models is an important efficiency gain that will greatly assist your future machine learning model building.

An important hyperparameter for the GBM algorithm is the learning rate. But which learning rate is best for this problem? By writing a loop to search through a number of possibilities, collating these and viewing them you can find the best one.

Possible learning rates to try include 0.001, 0.01, 0.05, 0.1, 0.2 and 0.5

You will have available X_train, X_test, y_train & y_test datasets, and GradientBoostingClassifier has been imported for you.

Instructions
100 XP
  • Create a learning_rates list for the learning rates, and a results_list to hold the accuracy score of your predictions.
  • Write a loop to create a GBM model for each learning rate mentioned and create predictions for each model.
  • Save the learning rate and accuracy score to a results_list.
  • Turn the results list into a DataFrame and print it out.