8000 [MRG] Improve error message with implicit pos_label in _binary_clf_curve by ogrisel · Pull Request #15562 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 10 commits into from
Nov 20, 2019

Conversation

ogrisel
Copy link
Member
@ogrisel ogrisel commented Nov 7, 2019

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.

@ogrisel ogrisel requested a review from qinhanmin2014 November 7, 2019 14:17
@ogrisel ogrisel changed the title Improve error message with implicit pos_label in _binary_clf_curve [MRG] Improve error message with implicit pos_label in _binary_clf_curve Nov 7, 2019
@ogrisel
Copy link
Member Author
ogrisel commented Nov 20, 2019

Thanks for your thoughtful reviews @qinhanmin2014 and @thomasjpfan. I think I have addressed your comments in my last push.

Copy link
Member
@thomasjpfan thomasjpfan left a 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
Copy link
Member

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?

Copy link
Member Author

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.

@ogrisel ogrisel merged commit 10b8bf7 into scikit-learn:master Nov 20, 2019
@ogrisel ogrisel deleted the improve-binary-clf-error-message branch November 20, 2019 17:06
@ogrisel
Copy link
Member Author
ogrisel commented Nov 20, 2019
8000

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 "
Copy link
Member

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

adrinjalali pushed a commit to adrinjalali/scikit-learn that referenced this pull request Nov 25, 2019
panpiort8 pushed a commit to panpiort8/scikit-learn that referenced this pull request Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0