You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe we should drop parameter pos_label in plot_roc_curve, because we do not have parameter pos_label in roc_auc_score. In roc_auc_score, for binary y_true, y_score is supposed to be the score of the class with greater label.
@amueller if you want to infer pos_label and allow users to specify pos_label manually, one possible solution is to define default pos_label=None as follows:
when y_true is in {-1, 1} or {0, 1}, pos_labe is set to 1, otherwise pos_label is set to the greater label.
This is consistent with brier_score_loss. Also see #10010#13628
The current error message is confusing because the data is binary (but has ambiguous string labels). But I think that automatically inferring pos_label=est.classes_[1] is arbitrary for string labels.
I think we should improve the error message but not try to automatically infer the positive class when we get string labels.
Maybe instead of "true positive rate" and "false positive rate" we should
label the axes "sensitivity to class 1" and "sensitivity to class 0" and
similar for other class labels....
Maybe instead of "true positive rate" and "false positive rate" we should
label the axes "sensitivity to class 1" and "sensitivity to class 0" and
similar for other class labels....
Actually we should rather use the string class labels in the axis labels (rather than the implicitly encoded labels).
@ogrisel@jnothman Actually I no longer regard this as a blocker. This is consistent with the repo if we think roc_auc_score is problematic (i.e., it should also support pos_label), because average_precision_score, roc_curve, precision_recall_curve do not infer pos_label automatically.
import numpy as np
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
X, y = load_iris(return_X_y=True)
X, y = X[y != 2], y[y != 2]
clf = LogisticRegression()
cross_val_score(clf, X, y, scoring="average_precision")
# array([1., 1., 1., 1., 1.])
y = np.array(["pos", "neg"])[y]
clf = LogisticRegression()
cross_val_score(clf, X, y, scoring="average_precision")
# ValueError: pos_label=1 is invalid. Set it to a label in y_true.
Activity
qinhanmin2014 commentedon Oct 21, 2019
Maybe we should drop parameter
pos_labelinplot_roc_curve, because we do not have parameterpos_labelinroc_auc_score. Inroc_auc_score, for binary y_true, y_score is supposed to be the score of the class with greater label.qinhanmin2014 commentedon Oct 28, 2019
@amueller if you want to infer pos_label and allow users to specify pos_label manually, one possible solution is to define default pos_label=None as follows:
when y_true is in {-1, 1} or {0, 1}, pos_labe is set to 1, otherwise pos_label is set to the greater label.
This is consistent with brier_score_loss. Also see #10010 #13628
qinhanmin2014 commentedon Oct 28, 2019
ping @thomasjpfan please share your opinion since it's a blocker, thanks :)
thomasjpfan commentedon Oct 29, 2019
In this case, since we have the trained estimator, we can infer the pos_label from
est.classes_[1]as suggested above.If a user wants to pass another
pos_labelwe can make sure thatpos_labelappears inest.classes_.ogrisel commentedon Oct 30, 2019
The current error message is confusing because the data is binary (but has ambiguous string labels). But I think that automatically inferring
pos_label=est.classes_[1]is arbitrary for string labels.I think we should improve the error message but not try to automatically infer the positive class when we get string labels.
ogrisel commentedon Oct 30, 2019
I am working on a PR.
qinhanmin2014 commentedon Oct 30, 2019
there's a PR :) #15316
ogrisel commentedon Oct 30, 2019
Sorry I had not seen it.... My PR #15405 is taking a different stand on the issue: refusing to infer when there is ambiguity.
jnothman commentedon Oct 30, 2019
ogrisel commentedon Nov 6, 2019
Actually we should rather use the string class labels in the axis labels (rather than the implicitly encoded labels).
jnothman commentedon Nov 6, 2019
ogrisel commentedon Nov 6, 2019
FPR is not sensitivity to class 0 right? TNR would be sensitivity to class 0. (I think). I am not sure how we could improve the curve axis labels.
qinhanmin2014 commentedon Nov 6, 2019
@ogrisel @jnothman Actually I no longer regard this as a blocker. This is consistent with the repo if we think roc_auc_score is problematic (i.e., it should also support pos_label), because average_precision_score, roc_curve, precision_recall_curve do not infer pos_label automatically.
qinhanmin2014 commentedon Nov 6, 2019
Perhaps we can simply use pos_label=1 as the default and never infer pos_label.
ogrisel commentedon Nov 6, 2019
I am actually thinking of the opposite: #15405 (comment)
jnothman commentedon Nov 6, 2019
amueller commentedon Nov 6, 2019
See my comment in #15405 (comment) please. I was a bit confused about what is happening.