Euclidean Distance and Manhattan Distance
Euclidean and Manhattan Distance
Euclidean Distance and Manhattan Distance are the two distances that we generally use to find distance between two data points. Use of this distance can be seen in algorithms like KNN, Kmean and Hierarchical clustering. We can check if there are any similarities between the two data points with the help of these distances.
The smallest possible distance between any two points is named as euclidean distance. This distance is calculated based on Pythagoras theorem as shown in the below figure.
Source: cdn-images-1.medium.com
For higher dimensions we can add the additional dimension.
This is case for any number of dimensions. Euclidean distance is used where we calculate the distance between any two points in a straight line irrespective of whether there are any other data points in between them. Ex. when we google to check distance between Cochin and Delhi in case of flight we get a straight point from Cochin to Delhi.
Some properties:
- It is symmetric, which means for all points 'a' and 'b', distance from a to b is same as b to a. The distance is independent of which point is taken as start or end.
- It is always positive, which means distance between any two points will always be positive.
- It follows triangle inequality, which means for every three points a, b, and c
Source: cheenta
Manhattan Distance
The distance between two points that is measured along the axis at right angles is called Manhattan distance.
In any modern structured city where all the houses are constructed in a proper block fashion, the distance between one house to the other is calculated via road (following the road pattern). We are not taking a shortcut distance which might even pass through other houses in between.
In general we need to try using both the distance in the machine learning use cases and do cross validation to check which is working best for our model.
References:
- Wikipedia
- YouTube Channel - sentdex
- YouTube Channel - Krish Naik
Comments
Post a Comment