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

FEA metadata routing for StackingClassifier and StackingRegressor #28701

Merged
merged 21 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions doc/metadata_routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ Meta-estimators and functions supporting metadata routing:
- :class:`sklearn.calibration.CalibratedClassifierCV`
- :class:`sklearn.compose.ColumnTransformer`
- :class:`sklearn.covariance.GraphicalLassoCV`
- :class:`sklearn.ensemble.StackingClassifier`
- :class:`sklearn.ensemble.StackingRegressor`
- :class:`sklearn.ensemble.VotingClassifier`
- :class:`sklearn.ensemble.VotingRegressor`
- :class:`sklearn.ensemble.BaggingClassifier`
Expand Down Expand Up @@ -316,13 +318,9 @@ Meta-estimators and tools not supporting metadata routing yet:
- :class:`sklearn.compose.TransformedTargetRegressor`
- :class:`sklearn.ensemble.AdaBoostClassifier`
- :class:`sklearn.ensemble.AdaBoostRegressor`
- :class:`sklearn.ensemble.StackingClassifier`
- :class:`sklearn.ensemble.StackingRegressor`
- :class:`sklearn.feature_selection.RFE`
- :class:`sklearn.feature_selection.RFECV`
- :class:`sklearn.feature_selection.SequentialFeatureSelector`
- :class:`sklearn.impute.IterativeImputer`
- :class:`sklearn.linear_model.RANSACRegressor`
- :class:`sklearn.model_selection.learning_curve`
- :class:`sklearn.model_selection.permutation_test_score`
- :class:`sklearn.model_selection.validation_curve`
Expand Down
4 changes: 2 additions & 2 deletions doc/modules/ensemble.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1581,8 +1581,8 @@ availability, tested in the order of preference: `predict_proba`,
`decision_function` and `predict`.

A :class:`StackingRegressor` and :class:`StackingClassifier` can be used as
any other regressor or classifier, exposing a `predict`, `predict_proba`, and
`decision_function` methods, e.g.::
any other regressor or classifier, exposing a `predict`, `predict_proba`, or
`decision_function` method, e.g.::

>>> y_pred = reg.predict(X_test)
>>> from sklearn.metrics import r2_score
Expand Down
14 changes: 13 additions & 1 deletion doc/whats_new/v1.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@ See :ref:`array_api` for more details.

**Classes:**

-
-

Metadata Routing
----------------

The following models now support metadata routing in one or more of their
methods. Refer to the :ref:`Metadata Routing User Guide <metadata_routing>` for
more details.

- |Feature| :class:`ensemble.StackingClassifier` and
:class:`ensemble.StackingRegressor` now support metadata routing and pass
``**fit_params`` to the underlying estimators via their `fit` methods.
:pr:`28701` by :user:`Stefanie Senger <StefanieSenger>`.

Changelog
---------
Expand Down
2 changes: 1 addition & 1 deletion sklearn/ensemble/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _fit_single_estimator(
estimator, X, y, fit_params, message_clsname=None, message=None
):
"""Private function used to fit an estimator within a job."""
# TODO(SLEP6): remove if condition for unrouted sample_weight when metadata
# TODO(SLEP6): remove if-condition for unrouted sample_weight when metadata
# routing can't be disabled.
if not _routing_enabled() and "sample_weight" in fit_params:
try:
Expand Down