mlxtend
mlxtend copied to clipboard
StackingCVClassifier: Passing parameters to the fit method of the underlying classifiers
I'm using StackingCVClassifier
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})
Unfortunately, The StackingClassifier & StackingCVClassifier don't accept a fit_params
argument yet. But it would be a worthwhile addition!
Would love to see this added to a v0.18/19 Roadmap since it didn't make it into v0.14. Willing to contribute.
I am currently a bit swamped -- the new semester just started plus I have a paper due next week, but I was planning to make a new mlxtend release this week (or very soon). The reason is that there were some bugs in the previous release, and there are some people in industry who can only install PyPI packages (not from GitHub directly) due to company firewalls.
To keep a long story short, if you are willing to contribute with a PR, that would be very appreciated!