Attend the Women in ML Symposium on December 7 Register now

tfa.metrics.hamming_distance

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

Computes hamming distance.

Hamming distance is for comparing two binary strings. It is the number of bit positions in which two bits are different.

actuals actual target value.
predictions predicted value.

hamming distance: float.

Usage:

y_true = np.array([1, 1, 0, 0, 1, 0, 1, 0, 0, 1], dtype=np.int32)
y_pred = np.array([1, 0, 0, 0, 1, 0, 0, 1, 0, 1], dtype=np.int32)
hamming_distance(y_true, y_pred).numpy()
0.3