Search for the optimal tree
In this exercise, you'll perform grid search using 5-fold cross validation to find dt's optimal hyperparameters. Note that because grid search is an exhaustive 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)
An untuned classification tree dt as well as the dictionary params_dt that you defined in the previous exercise are available in your workspace.
Questo esercizio fa parte del corso
Machine Learning with Tree-Based Models in Python
Istruzioni dell'esercizio
Import
GridSearchCVfromsklearn.model_selection.Instantiate a
GridSearchCVobject using 5-fold CV by setting the parameters:estimatortodt,param_gridtoparams_dtandscoringto'roc_auc'.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Import GridSearchCV
____
# Instantiate grid_dt
grid_dt = ____(estimator=____,
param_grid=____,
scoring=____,
cv=____,
n_jobs=-1)