-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[MRG + 1] Label warning #7802
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 + 1] Label warning #7802
Conversation
…al labels size and tests for such a case.
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.
Tests failing (unsurprisingly, given my comment)
@@ -1392,6 +1392,9 @@ class 2 1.00 0.67 0.80 3 | |||
else: | |||
labels = np.asarray(labels) | |||
|
|||
if len(labels) != len(target_names): |
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.
But target_names
is optional!
@@ -1392,6 +1392,9 @@ class 2 1.00 0.67 0.80 3 | |||
else: | |||
labels = np.asarray(labels) | |||
|
|||
if target_names is not None and len(labels) != len(target_names): | |||
warnings.warn("labels size does not match size of target_names") |
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.
Can you provide the number of labels and number of target_names in the message?
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.
sure
@@ -1393,7 +1393,7 @@ class 2 1.00 0.67 0.80 3 | |||
labels = np.asarray(labels) | |||
|
|||
if target_names is not None and len(labels) != len(target_names): | |||
warnings.warn("labels size, {}, does not match size of target_names, {}".format(len(labels), len(target_names)) |
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.
The line is to long now. You can also run flake8 or pyflakes locally to find these errors without running the continuous integration. I would recommend installing a flake8 plugin for your editor / IDE.
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.
Thanks for the advice, I wasn't aware of these tools. I got normal flake8 working but I use pycharm mostly and can't find a plugin for it (and the built in inspector doesn't catch line length. Any advice on an editor/IDE I could use?
LGTM apart from pep8 |
@amueller why do the lines I write that are over the 79 characters throw errors, but lines that were already in the files and are also over 79 characters not throw errors? examples of things that fail flake8 locally on my computer that I didn't write but do not fail here:
|
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.
made adjustments, please see latest commit
This is by design, we are only flake8-ing the lines that the PR changes. Look at https://github.com/scikit-learn/scikit-learn/blob/master/build_tools/travis/flake8_diff.sh for more details. |
…els size (scikit-learn#7802) * Added warning for classification_report when target_names doesn't equal labels size and tests for such a case.
…els size (scikit-learn#7802) * Added warning for classification_report when target_names doesn't equal labels size and tests for such a case.
…els size (scikit-learn#7802) * Added warning for classification_report when target_names doesn't equal labels size and tests for such a case.
…els size (scikit-learn#7802) * Added warning for classification_report when target_names doesn't equal labels size and tests for such a case.
…els size (scikit-learn#7802) * Added warning for classification_report when target_names doesn't equal labels size and tests for such a case.
Reference Issue
Fixes #7751
What does this implement/fix? Explain your changes.
Raises warning if length of labels doesn't equal length of target names for a classification report. Also included a test for this
Any other comments?