Preparing for RandomizedSearch
Last semester your professor challenged your class to build a predictive model to predict final exam test scores. You tried running a few different models by randomly selecting hyperparameters. However, running each model required you to code it individually.
After learning about RandomizedSearchCV(), you're revisiting your professors challenge to build the best model. In this exercise, you will prepare the three necessary inputs for completing a random search.
Questo esercizio fa parte del corso
Model Validation in Python
Istruzioni dell'esercizio
- Finalize the parameter dictionary by adding a list for the
max_depthparameter with options 2, 4, 6, and 8. - Create a random forest regression model with ten trees and a
random_stateof 1111. - Create a mean squared error scorer to use.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import make_scorer, mean_squared_error
# Finish the dictionary by adding the max_depth parameter
param_dist = {"____": [____],
"max_features": [2, 4, 6, 8, 10],
"min_samples_split": [2, 4, 8, 16]}
# Create a random forest regression model
rfr = ____(____=10, ____=1111)
# Create a scorer to use (use the mean squared error)
scorer = ____(____)