All problems
Macro Multiclass Dice
Problem
Compute the macro-averaged Dice coefficient over classes.
For each class Dice = 2 * intersection / (predicted + target), counted over pixels; classes whose denominator is zero are skipped. Return the mean over the remaining classes rounded to 4 decimal places, or 0.0 when every class is empty.
Test cases
case 1
in: [[[0,1],[2,2]],[[0,1],[2,2]],3]
expected: 1
case 2
in: [[[0,0],[1,1]],[[0,1],[1,0]],2]
expected: 0.5
case 3
in: [[[0,0]],[[0,0]],2]
expected: 1
Starter codePython
def macro_dice(pred, target, num_classes):
# Your code here
pass3 test cases · run your code against them in the editor