Search for the optimal forest
In this exercise, you'll perform grid search using 3-fold cross validation to find rf's optimal hyperparameters. To evaluate each model in the grid, you'll be using the negative mean squared error metric.
Note that because grid search is an exhaustive search process, it may take a lot time to train the model. Here you'll only be instantiating the GridSearchCV object without fitting it to the training set. As discussed in the video, you can train such an object similar to any scikit-learn estimator by using the .fit() method:
grid_object.fit(X_train, y_train)
The untuned random forests regressor model rf as well as the dictionary params_rf that you defined in the previous exercise are available in your workspace.
Deze oefening maakt deel uit van de cursus
Machine Learning with Tree-Based Models in Python
Oefeninstructies
Import
GridSearchCVfromsklearn.model_selection.Instantiate a
GridSearchCVobject using 3-fold CV by using negative mean squared error as the scoring metric.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Import GridSearchCV
____
# Instantiate grid_rf
grid_rf = ____(estimator=____,
param_grid=____,
scoring=____,
cv=____,
verbose=1,
n_jobs=-1)