ComenzarEmpieza gratis

Implementing GridSearch

You can now use the sklearn GridSearchCV() function to find the best combination of all of the max_depth and min_samples_leaf values you generated in the previous exercise.

Este ejercicio forma parte del curso

HR Analytics: Predicting Employee Churn in Python

Ver curso

Instrucciones del ejercicio

  • Import the GridSearchCV function
  • Apply a GridSearchCV() function to your model using the parameters dictionary you defined earlier. Save this as param_search.
  • Fit param_search to the training dataset.
  • Print the best parameters found using best_params_ attribute.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# import the GridSearchCV function
from sklearn.model_selection import ____

# set up parameters: done
parameters = dict(max_depth=depth, min_samples_leaf=samples)

# initialize the param_search function using the GridSearchCV function, initial model and parameters above
param_search = ____(model, parameters, cv=3)

# fit the param_search to the training dataset
____.fit(features_train, target_train)

# print the best parameters found
print(param_search.____)
Editar y ejecutar código