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

MAINT Parameters validation for metrics.precision_recall_curve() #25698

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
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 12 sklearn/metrics/_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ def _binary_clf_curve(y_true, y_score, pos_label=None, sample_weight=None):
return fps, tps, y_score[threshold_idxs]


@validate_params(
{
"y_true": ["array-like"],
"probas_pred": ["array-like"],
"pos_label": [Real, str, "boolean", None],
"sample_weight": ["array-like", None],
}
)
def precision_recall_curve(y_true, probas_pred, *, pos_label=None, sample_weight=None):
"""Compute precision-recall pairs for different probability thresholds.

Expand All @@ -839,11 +847,11 @@ def precision_recall_curve(y_true, probas_pred, *, pos_label=None, sample_weight

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.

probas_pred : ndarray of shape (n_samples,)
probas_pred : array-like of shape (n_samples,)
Target scores, can either be probability estimates of the positive
class, or non-thresholded measure of decisions (as returned by
`decision_function` on some classifiers).
Expand Down
1 change: 1 addition & 0 deletions 1 sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def _check_function_param_validation(
"sklearn.metrics.multilabel_confusion_matrix",
"sklearn.metrics.mutual_info_score",
"sklearn.metrics.pairwise.additive_chi2_kernel",
"sklearn.metrics.precision_recall_curve",
"sklearn.metrics.precision_recall_fscore_support",
"sklearn.metrics.r2_score",
"sklearn.metrics.roc_curve",
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.