10000 MNT Clean-up deprecations for 1.7: y_prob in brier_score_loss (#31141) · scikit-learn/scikit-learn@a6efcaf · GitHub
[go: up one dir, main page]

Skip to content

Commit a6efcaf

Browse files
authored
MNT Clean-up deprecations for 1.7: y_prob in brier_score_loss (#31141)
1 parent 75cb7c3 commit a6efcaf

File tree

2 files changed

+2
-52
lines changed

2 files changed

+2
-52
lines changed

sklearn/metrics/_classification.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,24 +3464,22 @@ def _validate_binary_probabilistic_prediction(y_true, y_prob, sample_weight, pos
34643464
@validate_params(
34653465
{
34663466
"y_true": ["array-like"],
3467-
"y_proba": ["array-like", Hidden(None)],
3467+
"y_proba": ["array-like"],
34683468
"sample_weight": ["array-like", None],
34693469
"pos_label": [Real, str, "boolean", None],
34703470
"labels": ["array-like", None],
34713471
"scale_by_half": ["boolean", StrOptions({"auto"})],
3472-
"y_prob": ["array-like", Hidden(StrOptions({"deprecated"}))],
34733472
},
34743473
prefer_skip_nested_validation=True,
34753474
)
34763475
def brier_score_loss(
34773476
y_true,
3478-
y_proba=None,
3477+
y_proba,
34793478
*,
34803479
sample_weight=None,
34813480
pos_label=None,
34823481
labels=None,
34833482
scale_by_half="auto",
3484-
y_prob="deprecated",
34853483
):
34863484
r"""Compute the Brier score loss.
34873485
@@ -3533,13 +3531,6 @@ def brier_score_loss(
35333531
35343532
.. versionadded:: 1.7
35353533
3536-
y_prob : array-like of shape (n_samples,)
3537-
Probabilities of the positive class.
3538-
3539-
.. deprecated:: 1.5
3540-
`y_prob` is deprecated and will be removed in 1.7. Use
3541-
`y_proba` instead.
3542-
35433534
Returns
35443535
-------
35453536
score : float
@@ -3598,24 +3589,6 @@ def brier_score_loss(
35983589
... )
35993590
0.146...
36003591
"""
3601-
# TODO(1.7): remove in 1.7 and reset y_proba to be required
3602-
# Note: validate params will raise an error if y_prob is not array-like,
3603-
# or "deprecated"
3604-
if y_proba is not None and not isinstance(y_prob, str):
3605-
raise ValueError(
3606-
"`y_prob` and `y_proba` cannot be both specified. Please use `y_proba` only"
3607-
" as `y_prob` is deprecated in v1.5 and will be removed in v1.7."
3608-
)
3609-
if y_proba is None:
3610-
warnings.warn(
3611-
(
3612-
"y_prob was deprecated in version 1.5 and will be removed in 1.7."
3613-
"Please use ``y_proba`` instead."
3614-
),
3615-
FutureWarning,
3616-
)
3617-
y_proba = y_prob
3618-
36193592
y_proba = check_array(
36203593
y_proba, ensure_2d=False, dtype=[np.float64, np.float32, np.float16]
36213594
)

sklearn/metrics/tests/test_classification.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,29 +3166,6 @@ def test_classification_metric_division_by_zero_nan_validaton(scoring):
31663166
cross_val_score(classifier, X, y, scoring=scoring, n_jobs=2, error_score="raise")
31673167

31683168

3169-
# TODO(1.7): remove
3170-
def test_brier_score_loss_deprecation_warning():
3171-
"""Check the message for future deprecation."""
3172-
# Check brier_score_loss function
3173-
y_true = np.array([0, 1, 1, 0, 1, 1])
3174-
y_pred = np.array([0.1, 0.8, 0.9, 0.3, 1.0, 0.95])
3175-
3176-
warn_msg = "y_prob was deprecated in version 1.5"
3177-
with pytest.warns(FutureWarning, match=warn_msg):
3178-
brier_score_loss(
3179-
y_true,
3180-
y_prob=y_pred,
3181-
)
3182-
3183-
error_msg = "`y_prob` and `y_proba` cannot be both specified"
3184-
with pytest.raises(ValueError, match=error_msg):
3185-
brier_score_loss(
3186-
y_true,
3187-
y_prob=y_pred,
3188-
y_proba=y_pred,
3189-
)
3190-
3191-
31923169
def test_d2_log_loss_score():
31933170
y_true = [0, 0, 0, 1, 1, 1]
31943171
y_true_string = ["no", "no", "no", "yes", "yes", "yes"]

0 commit comments

Comments
 (0)
0