Curriculum
Course: SCIPY
Login
Text lesson

Cosine Distance

It represents the cosine of the angle between two points, A and B.

Example

Calculate the cosine distance between the given points.

from scipy.spatial.distance import cosine

p1 = (10)
p2 = (102)

res = cosine(p1, p2)

print(res)

Result:

0.019419324309079777

Hamming Distance

It represents the proportion of bits where two binary sequences differ, serving as a way to measure distance between them.

Example

Calculate the Hamming distance between the given points.

from scipy.spatial.distance import hamming

p1 = (TrueFalseTrue)
p2 = (FalseTrueTrue)

res = hamming(p1, p2)

print(res)

Result:

0.666666666667