GeneralizedDiceScore
yields 0 scores when using per_class=True
for samples where class is not present
#2846
Labels
🐛 Bug
The current implementation of
GeneralizedDiceScore
yields scores of0.0
for samples that don't contain a particular class when calculating class-wise metrics viaper_class=True
.This leads to very low dice scores, particularly for rare classes and therefore makes the dice scores between classes incomparable.
To Reproduce
The following code sample calculates class-wise scores of
tensor([0.2500, 0.2500, 0.0000])
, even though all the predictions match the targets:Code sample
Expected behavior
I'd expect the above code sample to return
[1.0, 1.0, nan]
for the class-wise scores (nan
for the third class, given that this class is not present in any of the samples, therefore returning a 1.0 score might also be misleading). Also, samples where the class doesn't occur should not contribute to the dice score of that class.Environment
1.6.0
3.11.10
Additional context
Very similar to issue #2850.
The text was updated successfully, but these errors were encountered: