July 30, 2020
DISTANCE
There are three different ways to define the distance between two points.
Euclidean Distance
Manhatten Distance
Hamming Distance
Euclidean Distance is the most commonly used distance formula. To find the Euclidean Distance between two points, we first calculate the squared distance between each dimension. If we add up all of these squared distances and take the square root, we’ve computed the Euclidean Distance.
Manhatten Distance is like Euclidean Distance, but rather than summing the squared difference between each dimension, we instead sum the absolute value of the difference between each dimension.
Manhatten Distance will always be greater than or equal to the Euclidean Distance.
Hamming Distance - Instead of finding the difference of each dimension, Hamming distance only cares about wether the dimensions are exactly equal. When finding the Hamming Distance between two points, add one for every dimension that has different values.
In SciPy, we can use:
distance.euclidean( )
distance.cityblock( )
distance.hamming( )