-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Makes roc_auc_score and average_precision_score docstrings more explicit #9557
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
[MRG] Makes roc_auc_score and average_precision_score docstrings more explicit #9557
Conversation
Changes the description of the y_true parameter to be slightly more explicit about the allowed values.
Thanks! Can you also change the entry in |
I changed the
|
I'm not sure I understand |
Yeah, it's kind of weird how there are two modes that import numpy as np
from sklearn import metrics
y = np.array([1, 1, 2, 2])
scores = np.array([0.1, 0.4, 0.35, 0.8])
fpr, tpr, thresholds = metrics.roc_curve(y, scores, pos_label=2) Is totally fine because ValueError: Data is not binary and pos_label is not specified would be raised. |
Here is where the values in https://github.com/scikit-learn/scikit-learn/blob/baa20488/sklearn/metrics/ranking.py#L311 |
I would clarify "labels are not binary" as "labels are not {-1, 1} or {0, 1}". {2, 5} are also binary labels |
Thanks for the comment @amueller. I changed the
|
sklearn/metrics/ranking.py
Outdated
@@ -116,7 +116,8 @@ def average_precision_score(y_true, y_score, average="macro", | |||
Parameters | |||
---------- | |||
y_true : array, shape = [n_samples] or [n_samples, n_classes] | |||
True binary labels in binary label indicators. | |||
True binary labels (either {0, 1} or {-1, 1}) or binary label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are binary label indicators. Just drop "or binary label indicators" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point @jnothman, thanks
LGTM |
Reference Issue
Fixes issue #9554
What does this implement/fix? Explain your changes.
Changes the description of the
y_true
parameter formetrics.roc_auc_score
and
metrics.average_precision_score
to be slightly more explicit aboutthe allowed values. This is more in line with the
metrics.roc_curve
andmetrics.precision_recall_curve
description ofy_true
. Specifically, this PRmakes the following modification.
Current description:
True binary labels in binary label indicators.
Modified description:
True binary labels (either {0, 1} or {-1, 1}) or binary label indicators.
This could help with avoid confusion in situations like the following
which yields
Even though there are only two unique classes in
y_true
.