From c1f5d7653d3a5e76ffe44395990c7a53de8c7e49 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Sun, 28 Nov 2021 12:12:03 -0500 Subject: [PATCH 01/10] API Deprecates values in partial_dependence in favor of pdp_values --- doc/whats_new/v1.1.rst | 12 ++++- sklearn/inspection/_partial_dependence.py | 30 +++++++++--- .../tests/test_partial_dependence.py | 47 +++++++++++++++---- sklearn/utils/__init__.py | 16 +++++++ sklearn/utils/tests/test_utils.py | 27 +++++++++++ 5 files changed, 114 insertions(+), 18 deletions(-) diff --git a/doc/whats_new/v1.1.rst b/doc/whats_new/v1.1.rst index f755aeba20030..7a174253bd20d 100644 --- a/doc/whats_new/v1.1.rst +++ b/doc/whats_new/v1.1.rst @@ -113,10 +113,10 @@ Changelog - |Fix| :class:`decomposition.FastICA` now validates input parameters in `fit` instead of `__init__`. :pr:`21432` by :user:`Hannah Bohle ` and :user:`Maren Westermann `. - + - |Fix| :class:`decomposition.FactorAnalysis` now validates input parameters in `fit` instead of `__init__`. - :pr:`21713` by :user:`Haya ` and + :pr:`21713` by :user:`Haya ` and :user:`Krum Arnaudov `. - |Fix| :class:`decomposition.KernelPCA` now validates input parameters in @@ -154,6 +154,14 @@ Changelog ``bootstrap=False`` and ``max_samples`` is not ``None``. :pr:`21295` :user:`Haoyin Xu `. +:mod:`sklearn.inspection` +......................... + +- |API| :func:`inspection.partial_dependence` returns a :class:`utils.Bunch` with + new key: `pdp_values`. The `values` key is deprecated in favor of `pdp_values` + and the `values` key will be removed in 1.3. + :pr:`xxxxx` by `Thomas Fan`_. + :mod:`sklearn.impute` ..................... diff --git a/sklearn/inspection/_partial_dependence.py b/sklearn/inspection/_partial_dependence.py index 14a9e66456cc1..676f358511200 100644 --- a/sklearn/inspection/_partial_dependence.py +++ b/sklearn/inspection/_partial_dependence.py @@ -334,6 +334,14 @@ def partial_dependence( Only available when ``kind='both'``. values : seq of 1d ndarrays + The values with which the grid has been created. + + .. deprecated:: 1.1 + The key `values` has been deprecated in 1.1 and will be removed + in 1.3 in favor of `pdp_values`. See `pdp_values` for details + about the `values` attribute. + + pdp_values : seq of 1d ndarrays The values with which the grid has been created. The generated grid is a cartesian product of the arrays in ``values``. ``len(values) == len(features)``. The size of each array @@ -481,14 +489,22 @@ def partial_dependence( averaged_predictions = averaged_predictions.reshape( -1, *[val.shape[0] for val in values] ) + pdp_results = Bunch() + + msg = ( + "Key: 'values', is deprecated in 1.1 and will be " + "removed in 1.3. Please use 'pdp_values' instead" + ) + pdp_results._set_deprecated( + values, new_key="pdp_values", deprecated_key="values", warning_message=msg + ) if kind == "average": - return Bunch(average=averaged_predictions, values=values) + pdp_results["average"] = averaged_predictions elif kind == "individual": - return Bunch(individual=predictions, values=values) + pdp_results["individual"] = predictions else: # kind='both' - return Bunch( - average=averaged_predictions, - individual=predictions, - values=values, - ) + pdp_results["average"] = averaged_predictions + pdp_results["individual"] = predictions + + return pdp_results diff --git a/sklearn/inspection/tests/test_partial_dependence.py b/sklearn/inspection/tests/test_partial_dependence.py index 4e62f140c6953..295787be33c23 100644 --- a/sklearn/inspection/tests/test_partial_dependence.py +++ b/sklearn/inspection/tests/test_partial_dependence.py @@ -108,7 +108,7 @@ def test_output_shape(Estimator, method, data, grid_resolution, features, kind): kind=kind, grid_resolution=grid_resolution, ) - pdp, axes = result, result["values"] + pdp, axes = result, result["pdp_values"] expected_pdp_shape = (n_targets, *[grid_resolution for _ in range(len(features))]) expected_ice_shape = ( @@ -377,7 +377,7 @@ def test_partial_dependence_easy_target(est, power): est, features=[target_variable], X=X, grid_resolution=1000, kind="average" ) - new_X = pdp["values"][0].reshape(-1, 1) + new_X = pdp["pdp_values"][0].reshape(-1, 1) new_y = pdp["average"][0] # add polynomial features if needed new_X = PolynomialFeatures(degree=power).fit_transform(new_X) @@ -597,7 +597,7 @@ def test_partial_dependence_sample_weight(): pdp = partial_dependence(clf, X, features=[1], kind="average") - assert np.corrcoef(pdp["average"], pdp["values"])[0, 1] > 0.99 + assert np.corrcoef(pdp["average"], pdp["pdp_values"])[0, 1] > 0.99 def test_hist_gbdt_sw_not_supported(): @@ -635,8 +635,8 @@ def test_partial_dependence_pipeline(): ) assert_allclose(pdp_pipe["average"], pdp_clf["average"]) assert_allclose( - pdp_pipe["values"][0], - pdp_clf["values"][0] * scaler.scale_[features] + scaler.mean_[features], + pdp_pipe["pdp_values"][0], + pdp_clf["pdp_values"][0] * scaler.scale_[features] + scaler.mean_[features], ) @@ -704,11 +704,11 @@ def test_partial_dependence_dataframe(estimator, preprocessor, features): if preprocessor is not None: scaler = preprocessor.named_transformers_["standardscaler"] assert_allclose( - pdp_pipe["values"][1], - pdp_clf["values"][1] * scaler.scale_[1] + scaler.mean_[1], + pdp_pipe["pdp_values"][1], + pdp_clf["pdp_values"][1] * scaler.scale_[1] + scaler.mean_[1], ) else: - assert_allclose(pdp_pipe["values"][1], pdp_clf["values"][1]) + assert_allclose(pdp_pipe["pdp_values"][1], pdp_clf["pdp_values"][1]) @pytest.mark.parametrize( @@ -739,7 +739,7 @@ def test_partial_dependence_feature_type(features, expected_pd_shape): pipe, df, features=features, grid_resolution=10, kind="average" ) assert pdp_pipe["average"].shape == expected_pd_shape - assert len(pdp_pipe["values"]) == len(pdp_pipe["average"].shape) - 1 + assert len(pdp_pipe["pdp_values"]) == len(pdp_pipe["average"].shape) - 1 @pytest.mark.parametrize( @@ -779,3 +779,32 @@ def test_kind_average_and_average_of_individual(Estimator, data): pdp_ind = partial_dependence(est, X=X, features=[1, 2], kind="individual") avg_ind = np.mean(pdp_ind["individual"], axis=1) assert_allclose(avg_ind, pdp_avg["average"]) + + +# TODO(1.3): Remove when bunch values is deprecated in 1.3 +def test_partial_dependence_bunch_values_deprecated(): + """Test that deprecation warning is raised when values is accessed.""" + + est = LogisticRegression() + (X, y), _ = binary_classification_data + est.fit(X, y) + + pdp_avg = partial_dependence(est, X=X, features=[1, 2], kind="average") + + msg = ( + "Key: 'values', is deprecated in 1.1 and will be " + "removed in 1.3. Please use 'pdp_values' instead" + ) + + # Does not warn for "pdp_values" + with pytest.warns(None) as record: + pdp_values = pdp_avg["pdp_values"] + + assert not [str(rec.message) for rec in record] + + # Warns for "values" + with pytest.warns(FutureWarning, match=msg): + values = pdp_avg["values"] + + # "values" and "pdp_values" are the same object + assert values is pdp_values diff --git a/sklearn/utils/__init__.py b/sklearn/utils/__init__.py index 3d8a1ca87d210..83ef485aeafe0 100644 --- a/sklearn/utils/__init__.py +++ b/sklearn/utils/__init__.py @@ -107,6 +107,22 @@ class Bunch(dict): def __init__(self, **kwargs): super().__init__(kwargs) + # Map from deprecated key to warning message + self.__dict__["_deprecated_key_to_warnings"] = {} + + def __getitem__(self, key): + if key in self.__dict__["_deprecated_key_to_warnings"]: + warnings.warn( + self._deprecated_key_to_warnings[key], + FutureWarning, + ) + return super().__getitem__(key) + + def _set_deprecated(self, value, *, new_key, deprecated_key, warning_message): + """Set key in dictionary to be deprecated with its warning message.""" + self.__dict__["_deprecated_key_to_warnings"][deprecated_key] = warning_message + self[new_key] = self[deprecated_key] = value + def __setattr__(self, key, value): self[key] = value diff --git a/sklearn/utils/tests/test_utils.py b/sklearn/utils/tests/test_utils.py index 24638d26b6138..8714825306ab5 100644 --- a/sklearn/utils/tests/test_utils.py +++ b/sklearn/utils/tests/test_utils.py @@ -30,6 +30,7 @@ from sklearn.utils import is_scalar_nan from sklearn.utils import _to_object_array from sklearn.utils import _approximate_mode +from sklearn.utils import Bunch from sklearn.utils.fixes import parse_version from sklearn.utils._mocking import MockDataFrame from sklearn.utils._testing import SkipTest @@ -725,3 +726,29 @@ def test_to_object_array(sequence): assert isinstance(out, np.ndarray) assert out.dtype.kind == "O" assert out.ndim == 1 + + +def test_bunch_attribute_deprecation(): + """Check that bunch raises deprecation message with `__getattr__`.""" + bunch = Bunch() + values = np.asarray([1, 2, 3]) + msg = ( + "Key: 'values', is deprecated in 1.1 and will be " + "removed in 1.3. Please use 'pdp_values' instead" + ) + bunch._set_deprecated( + values, new_key="pdp_values", deprecated_key="values", warning_message=msg + ) + + # Does not warn for "pdp_values" + with pytest.warns(None) as record: + v = bunch["pdp_values"] + + assert not [str(rec.message) for rec in record] + assert v is values + + # Warns for "values" + with pytest.warns(FutureWarning, match=msg): + v = bunch["values"] + + assert v is values From d3ea5637c9134436b3a2e55754ab21e0a7189083 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Mon, 23 Jan 2023 18:52:03 +0100 Subject: [PATCH 02/10] revert merge conflict --- doc/whats_new/v1.1.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/doc/whats_new/v1.1.rst b/doc/whats_new/v1.1.rst index a2d209ef572b4..e213f385a78c9 100644 --- a/doc/whats_new/v1.1.rst +++ b/doc/whats_new/v1.1.rst @@ -548,13 +548,6 @@ Changelog features is large. :pr:`21109` by :user:`Smile `. -- |Fix| :class:`decomposition.FastICA` now validates input parameters in `fit` instead of `__init__`. - :pr:`21432` by :user:`Hannah Bohle ` and :user:`Maren Westermann `. - -- |Fix| :class:`decomposition.FactorAnalysis` now validates input parameters - in `fit` instead of `__init__`. - :pr:`21713` by :user:`Haya ` and - :user:`Krum Arnaudov `. - |Enhancement| The :class:`decomposition.MiniBatchDictionaryLearning` and :func:`decomposition.dict_learning_online` have been refactored and now have a stopping criterion based on a small change of the dictionary or objective function, From 11cc102aa8a59e2f35e50e75ca934a7ab6c6eb81 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Mon, 23 Jan 2023 18:53:39 +0100 Subject: [PATCH 03/10] update docstring pdp --- sklearn/inspection/_partial_dependence.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sklearn/inspection/_partial_dependence.py b/sklearn/inspection/_partial_dependence.py index b905633d80e2b..e93f2f998990b 100644 --- a/sklearn/inspection/_partial_dependence.py +++ b/sklearn/inspection/_partial_dependence.py @@ -367,22 +367,24 @@ def partial_dependence( values : seq of 1d ndarrays The values with which the grid has been created. - .. deprecated:: 1.1 - The key `values` has been deprecated in 1.1 and will be removed - in 1.3 in favor of `pdp_values`. See `pdp_values` for details + .. deprecated:: 1.3 + The key `values` has been deprecated in 1.3 and will be removed + in 1.5 in favor of `pdp_values`. See `pdp_values` for details about the `values` attribute. pdp_values : seq of 1d ndarrays The values with which the grid has been created. The generated grid is a cartesian product of the arrays in ``values``. - ``len(values) == len(features)``. The size of each array - ``values[j]`` is either ``grid_resolution``, or the number of + ``len(pdp_values) == len(features)``. The size of each array + ``pdp_values[j]`` is either ``grid_resolution``, or the number of unique values in ``X[:, j]``, whichever is smaller. + .. versionadded:: 1.3 + ``n_outputs`` corresponds to the number of classes in a multi-class setting, or to the number of tasks for multi-output regression. For classical regression and binary classification ``n_outputs==1``. - ``n_values_feature_j`` corresponds to the size ``values[j]``. + ``n_values_feature_j`` corresponds to the size ``pdp_values[j]``. See Also -------- From c1e752d37dda328042e68140a7e100c04a7331e6 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Mon, 23 Jan 2023 18:56:27 +0100 Subject: [PATCH 04/10] use pattern advised by pytest --- sklearn/inspection/tests/test_partial_dependence.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sklearn/inspection/tests/test_partial_dependence.py b/sklearn/inspection/tests/test_partial_dependence.py index 0791cb1c9b40d..9c30812b9d724 100644 --- a/sklearn/inspection/tests/test_partial_dependence.py +++ b/sklearn/inspection/tests/test_partial_dependence.py @@ -1,6 +1,7 @@ """ Testing for the partial dependence module. """ +import warnings import numpy as np import pytest @@ -838,7 +839,7 @@ def test_kind_average_and_average_of_individual(Estimator, data): assert_allclose(avg_ind, pdp_avg["average"]) -# TODO(1.3): Remove when bunch values is deprecated in 1.3 +# TODO(1.5): Remove when bunch values is deprecated in 1.5 def test_partial_dependence_bunch_values_deprecated(): """Test that deprecation warning is raised when values is accessed.""" @@ -853,14 +854,13 @@ def test_partial_dependence_bunch_values_deprecated(): "removed in 1.3. Please use 'pdp_values' instead" ) - # Does not warn for "pdp_values" - with pytest.warns(None) as record: + with warnings.catch_warnings(): + # Does not raise warnings with "pdp_values" + warnings.simplefilter("error") pdp_values = pdp_avg["pdp_values"] - assert not [str(rec.message) for rec in record] - - # Warns for "values" with pytest.warns(FutureWarning, match=msg): + # Warns for "values" values = pdp_avg["values"] # "values" and "pdp_values" are the same object From 3156224e8c19e2d5b1f847ee2e3ae7e3e16679a9 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Mon, 23 Jan 2023 18:58:14 +0100 Subject: [PATCH 05/10] add final full stop in error message --- sklearn/inspection/_partial_dependence.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/inspection/_partial_dependence.py b/sklearn/inspection/_partial_dependence.py index e93f2f998990b..e46f0bde688ae 100644 --- a/sklearn/inspection/_partial_dependence.py +++ b/sklearn/inspection/_partial_dependence.py @@ -560,8 +560,8 @@ def partial_dependence( pdp_results = Bunch() msg = ( - "Key: 'values', is deprecated in 1.1 and will be " - "removed in 1.3. Please use 'pdp_values' instead" + "Key: 'values', is deprecated in 1.1 and will be removed in 1.3. " + "Please use 'pdp_values' instead." ) pdp_results._set_deprecated( values, new_key="pdp_values", deprecated_key="values", warning_message=msg From 1e3432b5e2cb7e424d196ca915736feaae9d74fd Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 25 Jan 2023 13:31:17 -0500 Subject: [PATCH 06/10] TST Fixes failing tests --- sklearn/inspection/_plot/partial_dependence.py | 6 +++--- sklearn/utils/_bunch.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/inspection/_plot/partial_dependence.py b/sklearn/inspection/_plot/partial_dependence.py index bba8e0dea826f..d47f1771f3987 100644 --- a/sklearn/inspection/_plot/partial_dependence.py +++ b/sklearn/inspection/_plot/partial_dependence.py @@ -1256,7 +1256,7 @@ def plot( else: pd_results_ = [] for kind_plot, pd_result in zip(kind, self.pd_results): - current_results = {"values": pd_result["values"]} + current_results = {"values": pd_result["pdp_values"]} if kind_plot in ("individual", "both"): preds = pd_result.individual @@ -1274,7 +1274,7 @@ def plot( # get global min and max average predictions of PD grouped by plot type pdp_lim = {} for kind_plot, pdp in zip(kind, pd_results_): - values = pdp["values"] + values = pdp["pdp_values"] preds = pdp.average if kind_plot == "average" else pdp.individual min_pd = preds[self.target_idx].min() max_pd = preds[self.target_idx].max() @@ -1402,7 +1402,7 @@ def plot( ): avg_preds = None preds = None - feature_values = pd_result["values"] + feature_values = pd_result["pdp_values"] if kind_plot == "individual": preds = pd_result.individual elif kind_plot == "average": diff --git a/sklearn/utils/_bunch.py b/sklearn/utils/_bunch.py index 2a71c9317a38f..d90aeb7d93c74 100644 --- a/sklearn/utils/_bunch.py +++ b/sklearn/utils/_bunch.py @@ -31,7 +31,7 @@ def __init__(self, **kwargs): self.__dict__["_deprecated_key_to_warnings"] = {} def __getitem__(self, key): - if key in self.__dict__["_deprecated_key_to_warnings"]: + if key in self.__dict__.get("_deprecated_key_to_warnings", {}): warnings.warn( self._deprecated_key_to_warnings[key], FutureWarning, From b26101406b5949dba400005c349d27c2c167de8e Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 25 Jan 2023 14:58:38 -0500 Subject: [PATCH 07/10] TST Fixes failing tests --- sklearn/inspection/_plot/partial_dependence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/inspection/_plot/partial_dependence.py b/sklearn/inspection/_plot/partial_dependence.py index d47f1771f3987..afedb40ff53ff 100644 --- a/sklearn/inspection/_plot/partial_dependence.py +++ b/sklearn/inspection/_plot/partial_dependence.py @@ -1256,7 +1256,7 @@ def plot( else: pd_results_ = [] for kind_plot, pd_result in zip(kind, self.pd_results): - current_results = {"values": pd_result["pdp_values"]} + current_results = {"pdp_values": pd_result["pdp_values"]} if kind_plot in ("individual", "both"): preds = pd_result.individual From 5041ee840d76141f4a7877f2e83288afbafa68d0 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 25 Jan 2023 20:24:12 -0500 Subject: [PATCH 08/10] TST Fixes warnings in tests --- .../_plot/tests/test_plot_partial_dependence.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sklearn/inspection/_plot/tests/test_plot_partial_dependence.py b/sklearn/inspection/_plot/tests/test_plot_partial_dependence.py index 329485ba918d6..ff20572403e63 100644 --- a/sklearn/inspection/_plot/tests/test_plot_partial_dependence.py +++ b/sklearn/inspection/_plot/tests/test_plot_partial_dependence.py @@ -103,7 +103,7 @@ def test_plot_partial_dependence(grid_resolution, pyplot, clf_diabetes, diabetes target_idx = disp.target_idx line_data = line.get_data() - assert_allclose(line_data[0], avg_preds["values"][0]) + assert_allclose(line_data[0], avg_preds["pdp_values"][0]) assert_allclose(line_data[1], avg_preds.average[target_idx].ravel()) # two feature position @@ -243,7 +243,7 @@ def test_plot_partial_dependence_str_features( assert line.get_alpha() == 0.8 line_data = line.get_data() - assert_allclose(line_data[0], avg_preds["values"][0]) + assert_allclose(line_data[0], avg_preds["pdp_values"][0]) assert_allclose(line_data[1], avg_preds.average[target_idx].ravel()) # contour @@ -279,7 +279,7 @@ def test_plot_partial_dependence_custom_axes(pyplot, clf_diabetes, diabetes): target_idx = disp.target_idx line_data = line.get_data() - assert_allclose(line_data[0], avg_preds["values"][0]) + assert_allclose(line_data[0], avg_preds["pdp_values"][0]) assert_allclose(line_data[1], avg_preds.average[target_idx].ravel()) # contour @@ -466,7 +466,7 @@ def test_plot_partial_dependence_multiclass(pyplot): disp_target_0.pd_results, disp_symbol.pd_results ): assert_allclose(int_result.average, symbol_result.average) - assert_allclose(int_result["values"], symbol_result["values"]) + assert_allclose(int_result["pdp_values"], symbol_result["pdp_values"]) # check that the pd plots are different for another target disp_target_1 = PartialDependenceDisplay.from_estimator( From df04c7996f390f742a3b8729eb2fd59e4dc0111c Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 25 Jan 2023 20:25:00 -0500 Subject: [PATCH 09/10] TST Be specific about FutureWarning --- sklearn/inspection/tests/test_partial_dependence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/inspection/tests/test_partial_dependence.py b/sklearn/inspection/tests/test_partial_dependence.py index 9c30812b9d724..4593aa5dfc682 100644 --- a/sklearn/inspection/tests/test_partial_dependence.py +++ b/sklearn/inspection/tests/test_partial_dependence.py @@ -856,7 +856,7 @@ def test_partial_dependence_bunch_values_deprecated(): with warnings.catch_warnings(): # Does not raise warnings with "pdp_values" - warnings.simplefilter("error") + warnings.simplefilter("error", FutureWarning) pdp_values = pdp_avg["pdp_values"] with pytest.warns(FutureWarning, match=msg): From b5cc33a56cb2818111307f05fd8d9eff991a0ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20du=20Boisberranger?= <34657725+jeremiedbb@users.noreply.github.com> Date: Tue, 28 Feb 2023 19:54:25 +0100 Subject: [PATCH 10/10] Apply suggestions from code review --- sklearn/inspection/_partial_dependence.py | 4 ++-- sklearn/inspection/tests/test_partial_dependence.py | 4 ++-- sklearn/utils/tests/test_bunch.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sklearn/inspection/_partial_dependence.py b/sklearn/inspection/_partial_dependence.py index e46f0bde688ae..2ff8b78adc899 100644 --- a/sklearn/inspection/_partial_dependence.py +++ b/sklearn/inspection/_partial_dependence.py @@ -374,7 +374,7 @@ def partial_dependence( pdp_values : seq of 1d ndarrays The values with which the grid has been created. The generated - grid is a cartesian product of the arrays in ``values``. + grid is a cartesian product of the arrays in ``pdp_values``. ``len(pdp_values) == len(features)``. The size of each array ``pdp_values[j]`` is either ``grid_resolution``, or the number of unique values in ``X[:, j]``, whichever is smaller. @@ -560,7 +560,7 @@ def partial_dependence( pdp_results = Bunch() msg = ( - "Key: 'values', is deprecated in 1.1 and will be removed in 1.3. " + "Key: 'values', is deprecated in 1.3 and will be removed in 1.5. " "Please use 'pdp_values' instead." ) pdp_results._set_deprecated( diff --git a/sklearn/inspection/tests/test_partial_dependence.py b/sklearn/inspection/tests/test_partial_dependence.py index 4593aa5dfc682..812c059ca5f92 100644 --- a/sklearn/inspection/tests/test_partial_dependence.py +++ b/sklearn/inspection/tests/test_partial_dependence.py @@ -850,8 +850,8 @@ def test_partial_dependence_bunch_values_deprecated(): pdp_avg = partial_dependence(est, X=X, features=[1, 2], kind="average") msg = ( - "Key: 'values', is deprecated in 1.1 and will be " - "removed in 1.3. Please use 'pdp_values' instead" + "Key: 'values', is deprecated in 1.3 and will be " + "removed in 1.5. Please use 'pdp_values' instead" ) with warnings.catch_warnings(): diff --git a/sklearn/utils/tests/test_bunch.py b/sklearn/utils/tests/test_bunch.py index e76db309fe4d6..922e724663a34 100644 --- a/sklearn/utils/tests/test_bunch.py +++ b/sklearn/utils/tests/test_bunch.py @@ -11,8 +11,8 @@ def test_bunch_attribute_deprecation(): bunch = Bunch() values = np.asarray([1, 2, 3]) msg = ( - "Key: 'values', is deprecated in 1.1 and will be " - "removed in 1.3. Please use 'pdp_values' instead" + "Key: 'values', is deprecated in 1.3 and will be " + "removed in 1.5. Please use 'pdp_values' instead" ) bunch._set_deprecated( values, new_key="pdp_values", deprecated_key="values", warning_message=msg