Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fit_params in stacking #18028

Closed
a-wozniakowski opened this issue Jul 30, 2020 · 2 comments · Fixed by #28701
Closed

Support fit_params in stacking #18028

a-wozniakowski opened this issue Jul 30, 2020 · 2 comments · Fixed by #28701

Comments

@a-wozniakowski
Copy link

Currently, there is no support for **fit_params in the fit method of _BaseStacking:

def fit(self, X, y, sample_weight=None):

As introduced in issue #15953 for _MultiOutputEstimator, it seems natural to extend the utility to stacking. A proposed implementation in the base stacking class is as follows:

from ..utils.validation import _check_fit_params

def fit(self, X, y, sample_weight=None, **fit_params):
    # Right before predictions = Parallel...
    if fit_params:
        fit_params = _check_fit_params(X, fit_params)
    else:
        fit_params = (dict(sample_weight=sample_weight)
                      if sample_weight is not None
                      else None)
    # Then, utilize fit_params in the parallelized cross_val_predict

Subsequently, alter the fit methods for StackingClassifier and StackingRegressor such that they support **fit_params. If this is favorable, then I can write an implementation and start the pull request.

@jnothman
Copy link
Member

jnothman commented Jul 30, 2020 via email

@a-wozniakowski
Copy link
Author

@jnothman thanks for your reply. From an earlier issue, sample weights appear to be the underlying motivation for the design principle in FeatureUnion:

"I think fit_params is more or less just a more general way to implement sample_weights, with a slightly different API. I tried to implement sample_props once and it was mostly renaming fit_params (and sometimes moving it from __init__ to fit)"

Originally posted by @amueller in #7136 (comment)

With _MultiOutputEstimator and _BaseStacking there is also the motivation of early stopping (which does not apply to transformers). As the estimators in stacking may be heterogeneous, the name-based prefixing seems less error prone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants