Reputation: 1996
I have defined my parameter grid and gridsearch here. The weird thing is, the output does not include any of the parameter options I set. E.g. max features has been set to auto.
Have I done something wrong?
from sklearn.grid_search import GridSearchCV
param_grid = {
'bootstrap': [True],
'max_depth': [90, 100, 110],
'max_features': [2, 3, 10, 20],
'min_samples_leaf': [3, 4, 5, 10],
'min_samples_split': [2, 5, 8, 10, 12],
'n_estimators': [10, 20, 50, 60, 70]
}
model = RandomForestClassifier()
# Instantiate the grid search model
best = GridSearchCV(estimator = model, param_grid = param_grid,
cv = 3, n_jobs = -1, verbose = 2)
best.fit(x, y.ravel())
Upvotes: 0
Views: 877
Reputation: 3451
You have to take the return value of the best.fit()
function.
fitted_grid = best.fit(x, y.ravel())
best_classifier = fitted_grid.best_estimator_
best_parameters = fitted_grid.best_params_
I did not see that part in your code snippet, so maybe that's where you were missing something ?
Upvotes: 2