I'm running GridSearch CV to optimize the parameters of a classifier in scikit. Once I'm done, I'd like to know which parameters were chosen as the best.
Whenever I do so I get a AttributeError: 'RandomForestClassifier' object has no attribute 'best_estimator_'
, and can't tell why, as it seems to be a legitimate attribute on the documentation.
from sklearn.grid_search import GridSearchCV
X = data[usable_columns]
y = data[target]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
rfc = RandomForestClassifier(n_jobs=-1,max_features= 'sqrt' ,n_estimators=50, oob_score = True)
param_grid = {
'n_estimators': [200, 700],
'max_features': ['auto', 'sqrt', 'log2']
}
CV_rfc = GridSearchCV(estimator=rfc, param_grid=param_grid, cv= 5)
print '
',CV_rfc.best_estimator_
Yields:
`AttributeError: 'GridSearchCV' object has no attribute 'best_estimator_'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…