Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions sklearn/metrics/_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2864,6 +2864,14 @@ def log_loss(
return _weighted_sum(loss, sample_weight, normalize)


@validate_params(
{
"y_true": ["array-like"],
"pred_decision": ["array-like"],
"labels": ["array-like", None],
"sample_weight": ["array-like", None],
}
)
def hinge_loss(y_true, pred_decision, *, labels=None, sample_weight=None):
"""Average hinge loss (non-regularized).

Expand All @@ -2883,11 +2891,11 @@ def hinge_loss(y_true, pred_decision, *, labels=None, sample_weight=None):

Parameters
----------
y_true : array of shape (n_samples,)
y_true : array-like of shape (n_samples,)
True target, consisting of integers of two values. The positive label
must be greater than the negative label.

pred_decision : array of shape (n_samples,) or (n_samples, n_classes)
pred_decision : array-like of shape (n_samples,) or (n_samples, n_classes)
Predicted decisions, as output by decision_function (floats).

labels : array-like, default=None
Expand Down
1 change: 1 addition & 0 deletions sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def _check_function_param_validation(
"sklearn.metrics.fbeta_score",
"sklearn.metrics.get_scorer",
"sklearn.metrics.hamming_loss",
"sklearn.metrics.hinge_loss",
"sklearn.metrics.jaccard_score",
"sklearn.metrics.label_ranking_average_precision_score",
"sklearn.metrics.label_ranking_loss",
Expand Down