Metric for Accuracy of Multi Label Multi Class Prediction

Hamming Score is the fraction of correct predictions compared to the total labels. This is similar to Accuracy, and in fact they are interchangeable.

Hamming Score is simply Accuracy

hamming_score.pytruth = [0, 1, 1, 0, 0] # Multi hot labels for one input (class 1 and 2 are present)prediction = [1, 1, 1, 0, 0] # Predicted labels for the inputnum_classes = len(truth)num_samples = 1numerator = float(sum(truth & prediction))denominator = float(sum(truth | prediction))hamming_score = numerator / denominator

Accuracy