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
This would be an extension of my previous addition #14900, where I added the parameter zero_division for precision, recall, f1. Afterwards, it was added for jaccard as well.
Here, we would return np.nan when the metric is undefined. For the user to force this, she would pass zero_division=None or zero_division=np.nan. To be clear, in both cases, the result would be np.nan (even if passing None).
This would be useful if the metric is used downstream for some average, to be excluded, as e.g. pd.mean does. In case the metric included an average, then such behaviour would already be implemented here, ignoring the figures being undefined.
Describe your proposed solution
Allow zero_division to be None or np.nan. In both cases, disable the warning as we already do for zero_divsion 0 and
Behaviour for each metric when passing either None or np.nan as follows. Keep same as today for other values, i.e. back-compatible
Precision:
If pred_sum = 0, return np.nan
If average != None, ignore from average any class metric being undefined
Recall:
If true_sum = 0, return np.nan
If average != None, ignore from average any class metric being undefined
F-score:
if beta=inf, return recall, and beta=0, return precision
elif precision=0 or recall=0 (or both), return 0.
else return np.nan
If average != None, ignore from average any class metric being undefined
Jaccard:
if all labels and pred are 0, return np.nan
If average != None, ignore from average any class metric being undefined
Describe alternatives you've considered, if relevant
Describe the workflow you want to enable
This would be an extension of my previous addition #14900, where I added the parameter
zero_division
for precision, recall, f1. Afterwards, it was added for jaccard as well.Here, we would return np.nan when the metric is undefined. For the user to force this, she would pass
zero_division=None
orzero_division=np.nan
. To be clear, in both cases, the result would benp.nan
(even if passingNone
).This would be useful if the metric is used downstream for some average, to be excluded, as e.g. pd.mean does. In case the metric included an average, then such behaviour would already be implemented here, ignoring the figures being undefined.
Describe your proposed solution
Allow zero_division to be
None
ornp.nan
. In both cases, disable the warning as we already do forzero_divsion
0 andBehaviour for each metric when passing either
None
ornp.nan
as follows. Keep same as today for other values, i.e. back-compatiblePrecision:
np.nan
Recall:
np.nan
F-score:
beta=inf
, return recall, andbeta=0
, return precisionnp.nan
Jaccard:
np.nan
Describe alternatives you've considered, if relevant
No response
Additional context
#14876
#14900
The text was updated successfully, but these errors were encountered: