All problems
Hamming Loss for Segmentation Masks
Problem
Compute the Hamming loss between two lists of multi-label vectors.
Return the fraction of individual label positions that differ over all vectors, rounded to 4 decimal places.
Test cases
case 1
in: [[[1,0],[1,1]],[[1,0],[0,1]]]
expected: 0.25
case 2
in: [[[0,0]],[[1,1]]]
expected: 1
case 3
in: [[[1,1],[0,0]],[[1,1],[0,0]]]
expected: 0
Starter codePython
def hamming_loss(pred, target):
# Your code here
pass3 test cases · run your code against them in the editor