Attend the Women in ML Symposium on December 7 Register now


Stay organized with collections Save and categorize content based on your preferences.

Computes hamming loss.

Hamming loss is the fraction of wrong labels to the total number of labels.

In multi-class classification, hamming loss is calculated as the hamming distance between y_true and y_pred. In multi-label classification, hamming loss penalizes only the individual labels.

y_true actual target value.
y_pred predicted target value.
threshold Elements of y_pred greater than threshold are converted to be 1, and the rest 0. If threshold is None, the argmax is converted to 1, and the rest 0.
mode multi-class or multi-label.

hamming loss: float.