Passing parameters to the fit method of underlying classifiers via StackingCVClassifier in mlxtend package

162 Views Asked by At

I'm using StackingCVClassifier (from the mlxtend package) in Python and one of my classifiers is an XGBoostClassifier instance and I'm trying to pass a parameter (early_stopping_rounds or simply verbose) to its fit method via the fit method of the StackingCVClassifier object. The fit method does not seem to support this. The fit_transform method has a fit_params argument. But when I pass my parameter (e.g. **{'XGB_clf__early_stopping_rounds': 20}) it throw the following error:

fit() got an unexpected keyword argument 'XGB_clf__early_stopping_rounds.

Is this not supported? Or did I miss something?

Here is a sketch of what I'm trying to do:

XGB_clf = XGBClassifier()
other_clf = LogisticRegression()
stacked_clf = StackingCVClassifier(classifiers = [XGB_clf, other_clf], meta_classifier = LogisticRegression(), cv=2)
# trying to pass early_stopping_rounds to XGB_clf.fit
stacked_clf.fit(X_train, y_train, **{XGB_clf__early_stopping_rounds = 50})
1

There are 1 best solutions below

0
On

The developer of mlxtend indicated (link below) that, as of September 2018, this is not yet possible.

https://github.com/rasbt/mlxtend/issues/434