Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT Parameters validation for metrics.roc_curve #25108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
14 changes: 12 additions & 2 deletions sklearn/metrics/_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import warnings
from functools import partial
from numbers import Integral

import numpy as np
from scipy.sparse import csr_matrix, issparse
Expand Down Expand Up @@ -903,6 +904,15 @@ def precision_recall_curve(y_true, probas_pred, *, pos_label=None, sample_weight
return np.hstack((precision[sl], 1)), np.hstack((recall[sl], 0)), thresholds[sl]


@validate_params(
{
"y_true": ["array-like"],
"y_score": ["array-like"],
"pos_label": [Integral, str, None],
"sample_weight": ["array-like", None],
"drop_intermediate": ["boolean"],
}
)
def roc_curve(
y_true, y_score, *, pos_label=None, sample_weight=None, drop_intermediate=True
):
Expand All @@ -914,11 +924,11 @@ def roc_curve(

Parameters
----------
y_true : ndarray of shape (n_samples,)
y_true : array-like of shape (n_samples,)
True binary labels. If labels are not either {-1, 1} or {0, 1}, then
pos_label should be explicitly given.

y_score : ndarray of shape (n_samples,)
y_score : array-like of shape (n_samples,)
Target scores, can either be probability estimates of the positive
class, confidence values, or non-thresholded measure of decisions
(as returned by "decision_function" on some classifiers).
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 @@ -101,6 +101,7 @@ def _check_function_param_validation(
"sklearn.metrics.accuracy_score",
"sklearn.metrics.auc",
"sklearn.metrics.mean_absolute_error",
"sklearn.metrics.roc_curve",
"sklearn.metrics.zero_one_loss",
"sklearn.model_selection.train_test_split",
"sklearn.svm.l1_min_c",
Expand Down