Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the GridSearchCV class from scikit-learn.
ML Python
from sklearn.model_selection import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to create a parameter grid for tuning the 'max_depth' of a decision tree.
ML Python
param_grid = {'max_depth': [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the code to create a GridSearchCV object with a decision tree classifier and the parameter grid.
ML Python
grid_search = GridSearchCV(estimator=[1], param_grid=param_grid, cv=5)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to fit the GridSearchCV model on training data and get the best parameters.
ML Python
grid_search.[1](X_train, y_train) best_params = grid_search.[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to print the best score and make predictions on test data using the best estimator.
ML Python
print(f"Best score: {grid_search.[1]:.3f}") predictions = grid_search.[2].[3](X_test)
Drag options to blanks, or click blank then click option'
Attempts:
3 left