Lesson 54 of 60
pythonHyperparameter Tuning – Grid Search & Randomized Search
25 minutes
Course progress90%
Hyperparameter Tuning
Choosing the right hyperparameters often makes the difference between a mediocre and a state‑of‑the‑art model.
Grid Search (exhaustive)
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import RandomForestClassifier
param_grid = {
'n_estimators': [, , ],
: [, , ],
: [, , ]
}
grid = GridSearchCV(RandomForestClassifier(random_state=),
param_grid,
cv=,
scoring=,
n_jobs=-)
grid.fit(X_train, y_train)
(, grid.best_params_)
(, grid.best_score_)