【发布时间】:2019-03-29 15:45:42
【问题描述】:
我将 CalibratedClassifierCV 与 RandomForest 一起使用,并使用 GridSearch 来确定最佳参数。但是,当我使用 GridSearchCV 读回最佳参数时,它说 GridSearchCV 对象没有属性 'best_params_'
from sklearn.calibration import CalibratedClassifierCV
from classifiers import SVMClassification
from sklearn.model_selection import GridSearchCV
from imblearn.pipeline import Pipeline as imbpipeline
pipeline=imbpipeline([ ('oversample', Sampling(random_state=444)),('rf', rf())])
paramgrid=[ {'rf__max_depth': [8,10], 'rf__n_estimators':[3,5]}]
grid_search_rf = GridSearchCV(pipeline, param_grid=paramgrid,cv=3)
rf_calibrated=CalibratedClassifierCV(grid_search_rf,cv=5, method="sigmoid")
rf_calibrated.fit(x_labelled,y_labelled)
print(rf_calibrated.base_estimator.best_params_)
输出
AttributeError: 'GridSearchCV' 对象没有属性 'best_params_'
【问题讨论】: