Why do some metrics require num_classes=1
for binary classification?
#5792
Replies: 5 comments 2 replies
-
So I can try to clarify this a bit:
|
Beta Was this translation helpful? Give feedback.
-
@SkafteNicki thx for your answer and explanation
I agree with you, that in the binary case one would like to calculate the score on the positive class. I wonder, if there are any use cases, where the calculation using your defined
|
Beta Was this translation helpful? Give feedback.
-
so the usecase could be that the user wants set |
Beta Was this translation helpful? Give feedback.
-
Ok, thx for your explanations. |
Beta Was this translation helpful? Give feedback.
-
I feel this should be mentioned in the documentation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
❓ Why do some metrics require
num_classes=1
for binary classification?What is your question?
Why do some metrics require the argument
num_classes=1
for binary classification (and some don't) to give the correct results?I find it rather unintuitively to calculate Recall/Precision/F1 with the argument
num_classes=1
for a binary classification, whereas e.g. ConfusionMatrix requiresnum_classes=2
in the same situation.Furthermore, using Recall/Precision/F1 with
num_classes=2
for a binary classification gives wrong results - so this also might be considered a bug-report.It took me quite some time to figure out, why calculated metrics are different from what I calculated by hand from the confusion matrix.
Code
Results in
As one can see, Precision/Recall/F1 give different (wrong) results when setting
num_classes=2
in a binary classification.AveragePrecision doesn't even work with the binary usecase when setting
num_classes=2
whereas ConfusionMatrix doesn't work when settingnum_classes=1
.I wonder if there is a specific reason why one would set
num_classes=1
in a binary classification (where actually 2 classes exist).Wouldn't it be more straightforward to set
num_classes=2
for binary classification for all metrics?Beta Was this translation helpful? Give feedback.
All reactions