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.


Euclidean distance
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.


This is the case for 2-D data. 
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:
  1. Wikipedia
  2. YouTube Channel - sentdex
  3. YouTube Channel - Krish Naik



Comments

Popular posts from this blog

Ensemble Technique 2 : AdaBoost

Forecast Accuracy Metrics