Warning: This project is deprecated. TensorFlow Addons has stopped development, The project will only be providing minimal maintenance releases until May 2024. See the full announcement here or on github.

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