I am searching over parameters in pipeline using GridSearchCV
in Scikit.
I made my code work, but if I want to add class_weights
, I am hitting a wall.
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)
What is the proper way how to add this parameter to GridSearch?
Simple - You've got the wrong parameter name:
class_weight : dict, list of dicts, “balanced”, “balanced_subsample” or None, optional