[MRG] Improve error message with implicit pos_label in _binary_clf_curve#15562
Merged
ogrisel merged 10 commits intoscikit-learn:masterfrom Nov 20, 2019
Merged
Conversation
qinhanmin2014
approved these changes
Nov 7, 2019
qinhanmin2014
approved these changes
Nov 12, 2019
thomasjpfan
reviewed
Nov 12, 2019
Member
Author
|
Thanks for your thoughtful reviews @qinhanmin2014 and @thomasjpfan. I think I have addressed your comments in my last push. |
| 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 |
Member
There was a problem hiding this comment.
Are you sure that we should include O?
Member
Author
There was a problem hiding this comment.
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.
Member
Author
|
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 " |
This was referenced Nov 22, 2019
adrinjalali
pushed a commit
to adrinjalali/scikit-learn
that referenced
this pull request
Nov 25, 2019
jnothman
pushed a commit
that referenced
this pull request
Nov 28, 2019
panpiort8
pushed a commit
to panpiort8/scikit-learn
that referenced
this pull request
Mar 3, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_curveas shown in the test.