[MRG + 1] Label warning - #7802
Conversation
…al labels size and tests for such a case.
jnothman
left a comment
There was a problem hiding this comment.
Tests failing (unsurprisingly, given my comment)
| else: | ||
| labels = np.asarray(labels) | ||
|
|
||
| if len(labels) != len(target_names): |
| 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.
Can you provide the number of labels and number of target_names in the message?
| 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.
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.
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: |
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?