Passing parameters to the StackingCVClassifier itself within a pipeline

180 views
Skip to first unread message

Tom Grant

unread,
Sep 19, 2017, 5:19:55 PM9/19/17
to mlxtend

Hey all,

When using the ensemble classifiers as part of a grid search, is there any way of searching over the parameters of the ensembler itself, rather than just its
first level classifiers?

For example, with the StackingCVClassifier it may be interesting to see if using the class probabilities instead of the hard classes makes a difference.
Adapting the documented example:


sclf = StackingCVClassifier(classifiers=[clf1, clf2],
                            meta_classifier
=lr)

params = {'use_probas': [True, False],  # add the use_probas parameter to the search space
         
'kneighborsclassifier__n_neighbors': [1, 5],
         
'randomforestclassifier__n_estimators': [10, 50],
         
'meta-logisticregression__C': [0.1, 10.0]}

grid
= GridSearchCV(estimator=sclf,
                    param_grid
=params,
                    cv
=5,
                    refit
=True)

This however gives me an invalid parameter error:

ValueError: Invalid parameter use_probas for estimator StackingCVClassifier. Check the list of available parameters with `estimator.get_params().keys()`.

Am I missing something obvious?

Thanks,

Tom

Sebastian Raschka

unread,
Sep 19, 2017, 6:27:39 PM9/19/17
to Tom Grant, mlxtend
Thanks for the note, Tom. I wasn't even aware of that it is currently not supported. This can be easily addressed by making a small modification to the `get_params` method of the StackingCVClassifier. Hope to get to that soon. Just opened an issue here with more info: https://github.com/rasbt/mlxtend/issues/253

Best,
Sebastian
> --
> You received this message because you are subscribed to the Google Groups "mlxtend" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mlxtend+u...@googlegroups.com.
> To post to this group, send email to mlx...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mlxtend/ac1d378d-2464-4335-b7af-8b70acd7f7d6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Sebastian Raschka

unread,
Sep 20, 2017, 12:33:46 AM9/20/17
to mlxtend
Good news, Tom!

After posting the issue today, this issue already got addressed thanks to James Bourbeau and I just merged the PR.  

See
and

Before the next version release, it should already be usable via mlxtend 0.8.1dev, which can be installed via

pip install git+git://github.com/rasbt/mlxtend.git

Best,
Sebastian

> To unsubscribe from this group and stop receiving emails from it, send an email to mlxtend+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages