8000 MAINT Clean deprecated pdp_lim as constructor param of PartialDepende… · REDVM/scikit-learn@3e6d531 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e6d531

Browse files
jeremiedbbREDVM
authored andcommitted
MAINT Clean deprecated pdp_lim as constructor param of PartialDependenceDisplay (scikit-learn#26426)
1 parent 86c20fd commit 3e6d531

File tree

2 files changed

+0
-66
lines changed

2 files changed

+0
-66
lines changed

sklearn/inspection/_plot/partial_dependence.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numbers
2-
import warnings
32
from itertools import chain
43
from math import ceil
54

@@ -63,18 +62,6 @@ class PartialDependenceDisplay:
6362
deciles : dict
6463
Deciles for feature indices in ``features``.
6564
66-
pdp_lim : dict or None
67-
Global min and max average predictions, such that all plots will have
68-
the same scale and y limits. `pdp_lim[1]` is the global min and max for
69-
single partial dependence curves. `pdp_lim[2]` is the global min and
70-
max for two-way partial dependence curves. If `None`, the limit will be
71-
inferred from the global minimum and maximum of all predictions.
72-
73-
.. deprecated:: 1.1
74-
Pass the parameter `pdp_lim` to
75-
:meth:`~sklearn.inspection.PartialDependenceDisplay.plot` instead.
76-
It will be removed in 1.3.
77-
7865
kind : {'average', 'individual', 'both'} or list of such str, \
7966
default='average'
8067
Whether to plot the partial dependence averaged across all the samples
@@ -236,7 +223,6 @@ def __init__(
236223
feature_names,
237224
target_idx,
238225
deciles,
239-
pdp_lim="deprecated",
240226
kind="average",
241227
subsample=1000,
242228
random_state=None,
@@ -246,7 +232,6 @@ def __init__(
246232
self.features = features
247233
self.feature_names = feature_names
248234
self.target_idx = target_idx
249-
self.pdp_lim = pdp_lim
250235
self.deciles = deciles
251236
self.kind = kind
252237
self.subsample = subsample
@@ -1233,27 +1218,6 @@ def plot(
12331218
f" of such values. Currently, kind={self.kind!r}"
12341219
)
12351220

1236-
# FIXME: remove in 1.3
1237-
if self.pdp_lim != "deprecated":
1238-
warnings.warn(
1239-
(
1240-
"The `pdp_lim` parameter is deprecated in version 1.1 and will be "
1241-
"removed in version 1.3. Provide `pdp_lim` to the `plot` method."
1242-
"instead."
1243-
),
1244-
FutureWarning,
1245-
)
1246-
if pdp_lim is not None and self.pdp_lim != pdp_lim:
1247-
warnings.warn(
1248-
(
1249-
"`pdp_lim` has been passed in both the constructor and the"
1250-
" `plot` method. For backward compatibility, the parameter from"
1251-
" the constructor will be used."
1252-
),
1253-
UserWarning,
1254-
)
1255-
pdp_lim = self.pdp_lim
1256-
12571221
# Center results before plotting
12581222
if not centered:
12591223
pd_results_ = self.pd_results
< 10000 /div>

sklearn/inspection/_plot/tests/test_plot_partial_dependence.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import pytest
55
from numpy.testing import assert_allclose
6-
import warnings
76

87
from sklearn.datasets import load_diabetes
98
from sklearn.datasets import load_iris
@@ -857,35 +856,6 @@ def test_grid_resolution_with_categorical(pyplot, categorical_features, array_ty
857856
)
858857

859858

860-
# TODO(1.3): remove
861-
def test_partial_dependence_display_deprecation(pyplot, clf_diabetes, diabetes):
862-
"""Check that we raise the proper warning in the display."""
863-
disp = PartialDependenceDisplay.from_estimator(
864-
clf_diabetes,
865-
diabetes.data,
866-
[0, 2],
867-
grid_resolution=25,
868-
feature_names=diabetes.feature_names,
869-
)
870-
871-
deprecation_msg = "The `pdp_lim` parameter is deprecated"
872-
overwritting_msg = (
873-
"`pdp_lim` has been passed in both the constructor and the `plot` method"
874-
)
875-
876-
disp.pdp_lim = None
877-
# case when constructor and method parameters are the same
878-
with pytest.warns(FutureWarning, match=deprecation_msg):
879-
disp.plot(pdp_lim=None)
880-
# case when constructor and method parameters are different
881-
with warnings.catch_warnings(record=True) as record:
882-
warnings.simplefilter("always", FutureWarning)
883-
disp.plot(pdp_lim=(0, 1))
884-
assert len(record) == 2
885-
for warning in record:
886-
assert warning.message.args[0].startswith((deprecation_msg, overwritting_msg))
887-
888-
889859
@pytest.mark.parametrize("kind", ["individual", "average", "both"])
890860
@pytest.mark.parametrize("centered", [True, False])
891861
def test_partial_dependence_plot_limits_one_way(

0 commit comments

Comments
 (0)
0