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
When precision_recall_score is calculated with no true samples, a RuntimeWarning due to division by 0 is raised and nan is returned. However, when recall_score is calculated with no true labels, a UndefinedMetricWarning due to no true samples is raised.
For consistency, I think precision_recall_score should raise the same error and return 0.
/Users/.../scikit-learn/sklearn/metrics/classification.py:1293: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples.
(array([0., 1.]), array([0., 0.]), array([1]))
/Users/.../scikit-learn/sklearn/metrics/classification.py:1293: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples.
'recall', 'true', average, warn_for)
0.0
Actual Results
/Users/.../scikit-learn/sklearn/metrics/ranking.py:601: RuntimeWarning: invalid value encountered in true_divide
recall = tps / tps[-1]
(array([0., 1.]), array([nan, 0.]), array([1]))
/Users/.../scikit-learn/sklearn/metrics/classification.py:1293: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples.
'recall', 'true', average, warn_for)
0.0
Any updates on this issue? I think that average_precision_score also has the same issue. I am getting sklearn/metrics/_ranking.py:817: RuntimeWarning: invalid value encountered in true_divide when calling this function.
Description
When
precision_recall_score
is calculated with no true samples, aRuntimeWarning
due to division by 0 is raised andnan
is returned. However, whenrecall_score
is calculated with no true labels, aUndefinedMetricWarning
due to no true samples is raised.For consistency, I think
precision_recall_score
should raise the same error and return 0.Steps/Code to Reproduce
Expected Results
Actual Results
Versions
The text was updated successfully, but these errors were encountered: