8000 MAINT Clean deprecation for 1.2: DictionaryLearning (#24471) · thomasjpfan/scikit-learn@684f04d · GitHub
[go: up one dir, main page]

Skip to content

Commit 684f04d

Browse files
authored
MAINT Clean deprecation for 1.2: DictionaryLearning (scikit-learn#24471)
1 parent 83480df commit 684f04d

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

sklearn/decomposition/_dict_learning.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,19 +1181,8 @@ def _transform(self, X, dictionary):
11811181
SparseCoder."""
11821182
X = self._validate_data(X, reset=False)
11831183

1184-
# transform_alpha has to be changed in _transform
1185-
# this is done for consistency with the value of alpha
1186-
if (
1187-
hasattr(self, "alpha")
1188-
and self.alpha != 1.0
1189-
and self.transform_alpha is None
1190-
):
1191-
warnings.warn(
1192-
"By default transform_alpha will be equal to"
1193-
"alpha instead of 1.0 starting from version 1.2",
1194-
FutureWarning,
1195-
)
1196-
transform_alpha = 1.0 # TODO change to self.alpha in 1.2
1184+
if hasattr(self, "alpha") and self.transform_alpha is None:
1185+
transform_alpha = self.alpha
11971186
else:
11981187
transform_alpha = self.transform_alpha
11991188

@@ -1523,6 +1512,9 @@ class DictionaryLearning(_BaseSparseCoding, BaseEstimator):
15231512
threshold below which coefficients will be squashed to zero.
15241513
If `None`, defaults to `alpha`.
15251514
1515+
.. versionchanged:: 1.2
1516+
When None, default value changed from 1.0 to `alpha`.
1517+
15261518
n_jobs : int or None, default=None
15271519
Number of parallel jobs to run.
15281520
``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
@@ -1848,6 +1840,9 @@ class MiniBatchDictionaryLearning(_BaseSparseCoding, BaseEstimator):
18481840
threshold below which coefficients will be squashed to zero.
18491841
If `None`, defaults to `alpha`.
18501842
1843+
.. versionchanged:: 1.2
1844+
When None, default value changed from 1.0 to `alpha`.
1845+
18511846
verbose : bool or int, default=False
18521847
To control the verbosity of the procedure.
18531848

sklearn/decomposition/tests/test_dict_learning.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,15 +762,6 @@ def test_update_dict():
762762
assert_allclose(newd_batch, newd_online)
763763

764764

765-
# default value of batch_size changed. FIXME: remove in 1.3
766-
@pytest.mark.filterwarnings("ignore:The default value of batch_size will change")
767-
@pytest.mark.parametrize("Estimator", [DictionaryLearning, MiniBatchDictionaryLearning])
768-
def test_warning_default_transform_alpha(Estimator):
769-
dl = Estimator(alpha=0.1, max_iter=5)
770-
with pytest.warns(FutureWarning, match="default transform_alpha"):
771-
dl.fit_transform(X)
772-
773-
774765
# FIXME: remove in 1.3
775766
def test_dict_learning_online_n_iter_deprecated():
776767
# Check that an error is raised when a deprecated argument is set when max_iter

0 commit comments

Comments
 (0)
0