-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
precision_score shows incorrect value #10843
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
Comments
You might have expected [nan, 1, 1,] too. We raise a warning to tell you that we will set it to 0. |
I think the problem is that we do not raise a warning when there's only negative labels. E.g. precision_score([0, 0, 0], [0, 0, 0]) I vote for a warning to tell users that we set precision, recall, fbeta_score and support to 0 in this case. |
Yes, that's an issue.
But that's not the issue here. The complaint is that if y_true and y_pred
are equal, precision_score should always be 1.
A warning is indeed raised for the snippet presented in the issue
description.
|
Sorry, I haven't noticed that. So my opinion here is: |
Maybe raising a warning like "XXX is ill-defined and being set to 0.0 where there is only one label in both true and predicted samples." where XXX would be precision/recall/f_score and returning 0 could be added when there is only label in both y_true and y_pred. It could be added right after this, when scikit-learn/sklearn/metrics/classification.py Lines 1027 to 1030 in 158c7a5
|
Currently, scikit-learn/sklearn/metrics/tests/test_common.py Lines 937 to 946 in 4e87d93
and check_averaging calls _check_averaging : scikit-learn/sklearn/metrics/tests/test_common.py Lines 833 to 838 in 4e87d93
The multilabel case returns 1 and the current binary case returns also 1 (and returns 0 if the changes are made). Are these tests supposed to be modified thus? @qinhanmin2014 |
Description
precision_score shows incorrect value
Steps/Code to Reproduce
Expected Results
array([ 1., 1., 1.])
Actual Results
array([ 0., 1., 1.])
Versions
The text was updated successfully, but these errors were encountered: