Skip to content

Commit b679062

Browse files
authored
MNT remove deprecated loss_function_ in SGD (scikit-learn#29095)
1 parent d8185db commit b679062

File tree

4 files changed

+1
-47
lines changed

4 files changed

+1
-47
lines changed

sklearn/linear_model/_passive_aggressive.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ class PassiveAggressiveClassifier(BaseSGDClassifier):
142142
Number of weight updates performed during training.
143143
Same as ``(n_iter_ * n_samples + 1)``.
144144
145-
loss_function_ : callable
146-
Loss function used by the algorithm.
147-
148-
.. deprecated:: 1.4
149-
Attribute `loss_function_` was deprecated in version 1.4 and will be
150-
removed in 1.6.
151-
152145
See Also
153146
--------
154147
SGDClassifier : Incrementally trained logistic regression.

sklearn/linear_model/_perceptron.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ class Perceptron(BaseSGDClassifier):
123123
intercept_ : ndarray of shape (1,) if n_classes == 2 else (n_classes,)
124124
Constants in decision function.
125125
126-
loss_function_ : concrete LossFunction
127-
The function that determines the loss, or difference between the
128-
output of the algorithm and the target values.
129-
130126
n_features_in_ : int
131127
Number of features seen during :term:`fit`.
132128

sklearn/linear_model/_stochastic_gradient.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121
from ..exceptions import ConvergenceWarning
2222
from ..model_selection import ShuffleSplit, StratifiedShuffleSplit
23-
from ..utils import check_random_state, compute_class_weight, deprecated
23+
from ..utils import check_random_state, compute_class_weight
2424
from ..utils._param_validation import Hidden, Interval, StrOptions
2525
from ..utils.extmath import safe_sparse_dot
2626
from ..utils.metaestimators import available_if
@@ -321,16 +321,6 @@ def _make_validation_score_cb(
321321
classes=classes,
322322
)
323323

324-
# TODO(1.6): Remove
325-
# mypy error: Decorated property not supported
326-
@deprecated( # type: ignore
327-
"Attribute `loss_function_` was deprecated in version 1.4 and will be removed "
328-
"in 1.6."
329-
)
330-
@property
331-
def loss_function_(self):
332-
return self._loss_function_
333-
334324

335325
def _prepare_fit_binary(est, y, i, input_dtype):
336326
"""Initialization for fit_binary.
@@ -1159,12 +1149,6 @@ class SGDClassifier(BaseSGDClassifier):
11591149
The actual number of iterations before reaching the stopping criterion.
11601150
For multiclass fits, it is the maximum over every binary fit.
11611151
1162-
loss_function_ : concrete ``LossFunction``
1163-
1164-
.. deprecated:: 1.4
1165-
Attribute `loss_function_` was deprecated in version 1.4 and will be
1166-
removed in 1.6.
1167-
11681152
classes_ : array of shape (n_classes,)
11691153
11701154
t_ : int
@@ -2186,12 +2170,6 @@ class SGDOneClassSVM(BaseSGD, OutlierMixin):
21862170
Number of weight updates performed during training.
21872171
Same as ``(n_iter_ * n_samples + 1)``.
21882172
2189-
loss_function_ : concrete ``LossFunction``
2190-
2191-
.. deprecated:: 1.4
2192-
``loss_function_`` was deprecated in version 1.4 and will be removed in
2193-
1.6.
2194-
21952173
n_features_in_ : int
21962174
Number of features seen during :term:`fit`.
21972175

sklearn/linear_model/tests/test_sgd.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,19 +2216,6 @@ def test_sgd_numerical_consistency(SGDEstimator):
22162216
assert_allclose(sgd_64.coef_, sgd_32.coef_)
22172217

22182218

2219-
# TODO(1.6): remove
2220-
@pytest.mark.parametrize("Estimator", [SGDClassifier, SGDOneClassSVM])
2221-
def test_loss_attribute_deprecation(Estimator):
2222-
# Check that we raise the proper deprecation warning if accessing
2223-
# `loss_function_`.
2224-
X = np.array([[1, 2], [3, 4]])
2225-
y = np.array([1, 0])
2226-
est = Estimator().fit(X, y)
2227-
2228-
with pytest.warns(FutureWarning, match="`loss_function_` was deprecated"):
2229-
est.loss_function_
2230-
2231-
22322219
# TODO(1.7): remove
22332220
@pytest.mark.parametrize("Estimator", [SGDClassifier, SGDRegressor, SGDOneClassSVM])
22342221
def test_passive_aggressive_deprecated_average(Estimator):

0 commit comments

Comments
 (0)