diff --git a/doc/metadata_routing.rst b/doc/metadata_routing.rst index 0a73ab803271b..b7f95f3d608d7 100644 --- a/doc/metadata_routing.rst +++ b/doc/metadata_routing.rst @@ -248,7 +248,8 @@ should be passed to the estimator's scorer or not:: [sample_weight] are passed but are not explicitly set as requested or not requested for LogisticRegression.score, which is used within GridSearchCV.fit. Call `LogisticRegression.set_score_request({metadata}=True/False)` for each metadata - you want to request/ignore. + you want to request/ignore. See the Metadata Routing User guide + for more information. The issue can be fixed by explicitly setting the request value:: diff --git a/examples/model_selection/plot_cost_sensitive_learning.py b/examples/model_selection/plot_cost_sensitive_learning.py index c4dbb64535d69..9845d27661374 100644 --- a/examples/model_selection/plot_cost_sensitive_learning.py +++ b/examples/model_selection/plot_cost_sensitive_learning.py @@ -689,3 +689,6 @@ def business_metric(y_true, y_pred, amount): # historical data (offline evaluation) should ideally be confirmed by A/B testing # on live data (online evaluation). Note however that A/B testing models is # beyond the scope of the scikit-learn library itself. + +# At the end, we disable the configuration flag for metadata routing:: +sklearn.set_config(enable_metadata_routing=False) diff --git a/examples/release_highlights/plot_release_highlights_1_6_0.py b/examples/release_highlights/plot_release_highlights_1_6_0.py index 5a1214fc31b85..7e842659f018a 100644 --- a/examples/release_highlights/plot_release_highlights_1_6_0.py +++ b/examples/release_highlights/plot_release_highlights_1_6_0.py @@ -69,20 +69,20 @@ # a validation set. We can now have a pipeline which will transform the validation set # and pass it to the estimator:: # -# sklearn.set_config(enable_metadata_routing=True) -# est_gs = GridSearchCV( -# Pipeline( -# ( -# StandardScaler(), -# EstimatorWithValidationSet(...).set_fit_request(X_val=True, y_val=True), +# with sklearn.config_context(enable_metadata_routing=True): +# est_gs = GridSearchCV( +# Pipeline( +# ( +# StandardScaler(), +# EstimatorWithValidationSet(...).set_fit_request(X_val=True, y_val=True), +# ), +# # telling pipeline to transform these inputs up to the step which is +# # requesting them. +# transform_input=["X_val"], # ), -# # telling pipeline to transform these inputs up to the step which is -# # requesting them. -# transform_input=["X_val"], -# ), -# param_grid={"estimatorwithvalidationset__param_to_optimize": list(range(5))}, -# cv=5, -# ).fit(X, y, X_val=X_val, y_val=y_val) +# param_grid={"estimatorwithvalidationset__param_to_optimize": list(range(5))}, +# cv=5, +# ).fit(X, y, X_val=X_val, y_val=y_val) # # In the above code, the key parts are the call to `set_fit_request` to specify that # `X_val` and `y_val` are required by the `EstimatorWithValidationSet.fit` method, and diff --git a/sklearn/utils/_metadata_requests.py b/sklearn/utils/_metadata_requests.py index ebfbc41c0eab8..d7d77a74c6fa8 100644 --- a/sklearn/utils/_metadata_requests.py +++ b/sklearn/utils/_metadata_requests.py @@ -458,7 +458,10 @@ def _route_params(self, params, parent, caller): f" {self.owner}.{self.method}, which is used within" f" {parent}.{caller}. Call `{self.owner}" + set_requests_on - + "` for each metadata you want to request/ignore." + + "` for each metadata you want to request/ignore. See the" + " Metadata Routing User guide" + " for more" + " information." ) raise UnsetMetadataPassedError( message=message, @@ -1384,7 +1387,7 @@ def __init_subclass__(cls, **kwargs): for method in SIMPLE_METHODS: mmr = getattr(requests, method) - # set ``set_{method}_request``` methods + # set ``set_{method}_request`` methods if not len(mmr.requests): continue setattr( diff --git a/sklearn/utils/multiclass.py b/sklearn/utils/multiclass.py index 5df206259c5d1..6c089069387be 100644 --- a/sklearn/utils/multiclass.py +++ b/sklearn/utils/multiclass.py @@ -137,7 +137,7 @@ def is_multilabel(y): Returns ------- out : bool - Return ``True``, if ``y`` is in a multilabel format, else ```False``. + Return ``True``, if ``y`` is in a multilabel format, else ``False``. Examples --------