In multilabel classification one example can carry several tags at once: a photo may be both "beach" and "sunset". Exact-match accuracy counts a row as right only if every tag is right, which is harsh. Hamming loss counts the fraction of individual label slots that are wrong, so partial credit is given for getting most tags right.
Implement hamming_loss(y_true, y_pred). Both inputs are either 1-D label vectors (single-label) or 2-D binary matrices of shape (n_samples, n_labels). Return the fraction of entries where they differ.
ValueError.ValueError.[0, 1].Open one at a time. Each gives away a little more than the last.
y_true != y_pred gives a boolean array of the same shape, whether it is 1-D or 2-D.
np.mean over that boolean array counts the wrong slots out of the total, which is the answer.
No results yet
Run your code to check it against the examples, or submit to run every test.