It represents the cosine of the angle between two points, A and B.
Calculate the cosine distance between the given points.
from scipy.spatial.distance import cosine p1 = (1, 0) p2 = (10, 2) res = cosine(p1, p2) print(res) |
0.019419324309079777 |
It represents the proportion of bits where two binary sequences differ, serving as a way to measure distance between them.
Calculate the Hamming distance between the given points.
from scipy.spatial.distance import hamming p1 = (True, False, True) p2 = (False, True, True) res = hamming(p1, p2) print(res) |
0.666666666667 |