-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] Improve error message with implicit pos_label in _binary_clf_curve #15562
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] Improve error message with implicit pos_label in _binary_clf_curve #15562
Conversation
Thanks for your thoughtful reviews @qinhanmin2014 and @thomasjpfan. I think I have addressed your comments in my last push. |
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.
LGTM
np.array_equal(classes, [1]))): | ||
raise ValueError("Data is not binary and pos_label is not specified") | ||
if (pos_label is None and ( | ||
classes.dtype.kind in ('O', 'U', 'S') or |
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.
Are you sure that we should include O?
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.
I think so: object dtype is the default dtype used by pandas when parsing a CSV file with string columns that typically encode the target variable in a classification problem for instance.
Merged! |
classes_repr = ", ".join(repr(c) for c in classes) | ||
raise ValueError("y_true takes value in {{{classes_repr}}} and " | ||
"pos_label is not specified: either make y_true " | ||
"take integer value in {{0, 1}} or {{-1, 1}} or " |
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.
"integer value" is not correct @ogrisel
This takes the good part of #15405 that was closed when we decided to drop the pos_label argument of plot_roc_curve.
However this improvement in the error message was still useful for other functions such as
precision_recall_curve
as shown in the test.