Save the date! Google I/O returns May 18-20 Register now

tfa.metrics.hamming_distance

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