Below is my pipeline and it seems that I can\'t pass the parameters to my models by using the ModelTransformer class, which I take it from the link (http://zacstewart.com/20
GridSearchCV
has a special naming convention for nested objects. In your case ess__rfc__n_estimators
stands for ess.rfc.n_estimators
, and, according to the definition of the pipeline
, it points to the property n_estimators
of
ModelTransformer(RandomForestClassifier(n_jobs=-1, random_state=1, n_estimators=100)))
Obviously, ModelTransformer
instances don't have such property.
The fix is easy: in order to access underlying object of ModelTransformer
one needs to use model
field. So, grid parameters become
parameters = {
'ess__rfc__model__n_estimators': (100, 200),
}
P.S. it's not the only problem with your code. In order to use multiple jobs in GridSearchCV, you need to make all objects you're using copy-able. This is achieved by implementing methods get_params
and set_params
, you can borrow them from BaseEstimator mixin.