Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 6 commits into from
Feb 26, 2019
Merged

MNT Consistent warning and more doc about the edge cases of P/R/F #13143

merged 6 commits into from
Feb 26, 2019

Conversation

qinhanmin2014
Copy link
Member

@qinhanmin2014 qinhanmin2014 commented Feb 12, 2019

Fixes #10812
Fixes #10843 (I think)

(1) Raise consistent warning about the edge cases of P/R/F, current behavior:

precision_score([0, 0], [0, 0], average="binary")
# no warning
precision_score(np.array([[0, 0], [0, 0]]), np.array([[0, 0], [0, 0]]), average=None)
# UndefinedMetricWarning

(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.

Copy link
Member

@jnothman jnothman left a 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.

jnothman added a commit to jnothman/scikit-learn that referenced this pull request Feb 13, 2019
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Feb 13, 2019
@qinhanmin2014
Copy link
Member Author

ping @amueller @adrinjalali @rth to see if you have time.
We need this to fix our jaccard_score (#13151). I guess we might solve this long-standing issue during the sprint.

Notes
-----
When ``true positive + false positive == 0`` or
``true positive + false negative == 0``, f-score will be set to 0
Copy link
Member

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.

Copy link
Member

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

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?

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'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.

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrinjalali adrinjalali merged commit 2237b17 into scikit-learn:master Feb 26, 2019
@qinhanmin2014 qinhanmin2014 deleted the PRF-warning branch March 3, 2019 12:04
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
…ikit-learn#13143)

* consistent error message

* new test

* ignore warnings

* notes

* joel's comment

* adrin's comment
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
…ikit-learn#13143)

* consistent error message

* new test

* ignore warnings

* notes

* joel's comment

* adrin's comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants