You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
A warning is indeed raised for the snippet presented in the issue description.
Sorry, I haven't noticed that.
So my opinion here is:
(1) Keep the current behavior as I suppose there's no clear definition of precision_score when there's only negative labels.
(2) Also raise similar warning for precision_score([0, 0, 0], [0, 0, 0])
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 present_labels.size == 1 and XXX would be determined by the argument warn_for.
Currently, precision_score([0, 0, 0], [0, 0, 0]) returns 1. If 0 is returned, some tests fail (1 is expected) like test_averaging_multilabel_all_ones :
Activity
jnothman commentedon Mar 21, 2018
You might have expected [nan, 1, 1,] too. We raise a warning to tell you that we will set it to 0.
qinhanmin2014 commentedon Mar 21, 2018
I think the problem is that we do not raise a warning when there's only negative labels. E.g.
I vote for a warning to tell users that we set precision, recall, fbeta_score and support to 0 in this case.
jnothman commentedon Mar 21, 2018
qinhanmin2014 commentedon Mar 22, 2018
Sorry, I haven't noticed that.
So my opinion here is:
(1) Keep the current behavior as I suppose there's no clear definition of precision_score when there's only negative labels.
(2) Also raise similar warning for
precision_score([0, 0, 0], [0, 0, 0])johannfaouzi commentedon Mar 29, 2018
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
present_labels.size == 1and XXX would be determined by the argumentwarn_for.scikit-learn/sklearn/metrics/classification.py
Lines 1027 to 1030 in 158c7a5
johannfaouzi commentedon Mar 30, 2018
Currently,
precision_score([0, 0, 0], [0, 0, 0])returns 1. If 0 is returned, some tests fail (1 is expected) like test_averaging_multilabel_all_ones :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