-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
MNT Consistent warning and more doc about the edge cases of P/R/F #13143
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
Conversation
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 see now how there is no warning with all-zeros.
ping @amueller @adrinjalali @rth to see if you have time. |
sklearn/metrics/classification.py
Outdated
Notes | ||
----- | ||
When ``true positive + false positive == 0`` or | ||
``true positive + false negative == 0``, f-score will be set to 0 |
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.
f_score
returns 0 and raises an UndefinedMetricWarning
.
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.
similar for the other notes.
raise ValueError("pos_label=%r is not a valid label: %r" % | ||
(pos_label, present_labels)) | ||
if pos_label not in present_labels and len(present_labels) >= 2: | ||
raise ValueError("pos_label=%r is not a valid label: %r" % |
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'm a bit confused here. This is the only functional part which is changing, but all the new tests are only testing the warning messages. There's no new test which test this change in behavior (i.e. not returning 0,0,0,0).
Doesn't this need a whats_new entry?
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'm a bit confused here. This is the only functional part which is changing, but all the new tests are only testing the warning messages. There's no new test which test this change in behavior (i.e. not returning 0,0,0,0).
We now calculate these values manually and raise consistent warning in _prf_divide. I guess we don't need a what's new here since the users will only get some extra warnings.
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 @qinhanmin2014
…ikit-learn#13143) * consistent error message * new test * ignore warnings * notes * joel's comment * adrin's comment
…/R/F (scikit-learn#13143)" This reverts commit d931610.
…/R/F (scikit-learn#13143)" This reverts commit d931610.
…ikit-learn#13143) * consistent error message * new test * ignore warnings * notes * joel's comment * adrin's comment
Fixes #10812
Fixes #10843 (I think)
(1) Raise consistent warning about the edge cases of P/R/F, current behavior:
(2) Add some docs to tell users how we handle these edge cases
There's not a clear definition of these edge cases, so I think it's OK to tell users our solution.