BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Machine Learning with Tree-Based Models in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Import GridSearchCV from sklearn.model_selection.

  • Instantiate a GridSearchCV object using 5-fold CV by setting the parameters:

    • estimator to dt, param_grid to params_dt and

    • scoring to 'roc_auc'.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import GridSearchCV
____

# Instantiate grid_dt
grid_dt = ____(estimator=____,
                       param_grid=____,
                       scoring=____,
                       cv=____,
                       n_jobs=-1)
Kodu Düzenle ve Çalıştır