8000 MAINT Parameters validation for metrics.hinge_loss (#25880) · scikit-learn/scikit-learn@f151833 · GitHub
[go: up one dir, main page]

Skip to content

Commit f151833

Browse files
MAINT Parameters validation for metrics.hinge_loss (#25880)
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
1 parent b85bf9c commit f151833

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

sklearn/metrics/_classification.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,6 +2864,14 @@ def log_loss(
28642864
return _weighted_sum(loss, sample_weight, normalize)
28652865

28662866

2867+
@validate_params(
2868+
{
2869+
"y_true": ["array-like"],
2870+
"pred_decision": ["array-like"],
2871+
"labels": ["array-like", None],
2872+
"sample_weight": ["array-like", None],
2873+
}
2874+
)
28672875
def hinge_loss(y_true, pred_decision, *, labels=None, sample_weight=None):
28682876
"""Average hinge loss (non-regularized).
28692877
@@ -2883,11 +2891,11 @@ def hinge_loss(y_true, pred_decision, *, labels=None, sample_weight=None):
28832891
28842892
Parameters
28852893
----------
2886-
y_true : array of shape (n_samples,)
2894+
y_true : array-like of shape (n_samples,)
28872895
True target, consisting of integers of two values. The positive label
28882896
must be greater than the negative label.
28892897
2890-
pred_decision : array of shape (n_samples,) or (n_samples, n_classes)
2898+
pred_decision : array-like of shape (n_samples,) or (n_samples, n_classes)
28912899
Predicted decisions, as output by decision_function (floats).
28922900
28932901
labels : array-like, default=None

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def _check_function_param_validation(
163163
"sklearn.metrics.fbeta_score",
164164
"sklearn.metrics.get_scorer",
165165
"sklearn.metrics.hamming_loss",
166+
"sklearn.metrics.hinge_loss",
166167
"sklearn.metrics.jaccard_score",
167168
"sklearn.metrics.label_ranking_average_precision_score",
168169
"sklearn.metrics.label_ranking_loss",

0 commit comments

Comments
 (0)
0