Complete the code to import the GridSearchCV class from scikit-learn.
from sklearn.model_selection import [1]
The GridSearchCV class is imported from sklearn.model_selection to perform hyperparameter tuning using grid search.
Complete the code to create a parameter grid for tuning the 'max_depth' of a decision tree.
param_grid = {'max_depth': [1]The parameter grid must be a dictionary with keys as parameter names and values as lists of possible values. Here, [1, 2, 3, 4, 5] is a list of depths to try.
Fix the error in the code to create a GridSearchCV object with a decision tree classifier and the parameter grid.
grid_search = GridSearchCV(estimator=[1], param_grid=param_grid, cv=5)
The estimator argument requires an instance of the model, so you must call DecisionTreeClassifier() with parentheses to create it.
Fill both blanks to fit the GridSearchCV model on training data and get the best parameters.
grid_search.[1](X_train, y_train) best_params = grid_search.[2]
First, you fit the grid search object on training data. Then, you access best_params_ to see the best hyperparameters found.
Fill all three blanks to print the best score and make predictions on test data using the best estimator.
print(f"Best score: {grid_search.[1]:.3f}") predictions = grid_search.[2].[3](X_test)
The best_score_ attribute shows the best cross-validation score. The best_estimator_ is the model with the best parameters, and you call its predict method on test data.
