Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1f4b882

Browse filesBrowse files
bharatr21jeremiedbb
authored and
Itay
committed
MAINT Parameters validation for metrics.hinge_loss (scikit-learn#25880)
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
1 parent 13149ab commit 1f4b882
Copy full SHA for 1f4b882

File tree

Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed

‎sklearn/metrics/_classification.py

Copy file name to clipboardExpand all lines: sklearn/metrics/_classification.py
+10-2Lines 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

Copy file name to clipboardExpand all lines: sklearn/tests/test_public_functions.py
+1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.