Macro F1 score calculation for binary classification not working as expected #2549
Unanswered
96francesco
asked this question in
Classification
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, I am encountering a discrepancy in the macro F1 score calculation when using torchmetrics for binary classification. The macro F1 score calculated using torchmetrics is identical to the F1 score of class 1, rather than the average of the F1 scores for both classes. I am not sure if this is expected behavior or a potential issue. I was not able to calculate the F1 score for separate classes with BinaryF1Score, so I opted to use the multiclass setting.
I am encountering this error with a CNN for semantic segmentation on satellite images, but I get the same discrepancy with a mock dataset and model.
Here is the code:
I would expect to obtain a macro F1 score that is the average of the F1 scores of both classes with torchmetrics, but this is the result:
As you can see, the macro F1 score calculated with torchmetrics equals the F1 score of class 1.
Some details of my environment:
Beta Was this translation helpful? Give feedback.
All reactions