【发布时间】:2016-08-29 12:20:32
【问题描述】:
我正在 Scikit 中使用 GridSearchCV 搜索管道中的参数。
我让我的代码工作了,但如果我想添加class_weights,我就碰壁了。
from sklearn.pipeline import Pipeline
RFC = RandomForestClassifier()
PCA = PCA()
pipe = Pipeline(steps=[('PCA', PCA), ('RFC', RFC)])
param_dict = {'RFC__n_estimators': [100,150],
'RFC__class_weights': [{0:1,1:2},{0:1,1:4}],
'PCA__n_components': [60,80]}
from sklearn.grid_search import GridSearchCV
estimator = GridSearchCV(pipe, param_dict, scoring='roc_auc')
estimator.fit(X_train, y_train)
如何将此参数添加到 GridSearch 的正确方法是什么?
【问题讨论】:
标签: python scikit-learn pipeline grid-search