Recherche de grille Python

from sklearn.model_selection import GridSearchCV

params = {
    'n_estimators': [5, 10, 20],
    'max_depth': [1, 5, 10],
}

grid_search = GridSearchCV(RandomForestRegressor(), param_grid=params, n_jobs=-1)
grid_search.fit(X_train, y_train)
score = np.round(grid_search.score(X_test, y_test), 3)
print(f"Best random forest classifier score: {score}")
grid_search.best_estimator_, grid_search.best_params_
Adventurous Addax