[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 specifiedwould 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
| ---------- | ||
| 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.
These are binary label indicators. Just drop "or binary label indicators" here.
|
LGTM |
Reference Issue
Fixes issue #9554
What does this implement/fix? Explain your changes.
Changes the description of the
y_trueparameter formetrics.roc_auc_scoreand
metrics.average_precision_scoreto be slightly more explicit aboutthe allowed values. This is more in line with the
metrics.roc_curveandmetrics.precision_recall_curvedescription 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.