Whether it is a supervised or unsupervised algorithm, distance metrics play an important role in Machine Learning. Different distance measures are to be chosen depending on the types of data. So it is important that we understand these metrics and how to implement/calculate them. In this article, we will go through 5 of the most commonly used distance metrics.

1. Euclidean Distance

Euclidean distance is the straight line distance between two data points in Euclidean space. It is also called as L2 norm or L2 distance.

Image for post

Source: Wikipedia

Two dimensions

If p=(p1, p2) and q=(q1, q2) are two points in the Euclidean space, the Euclidean distance is given by -

Image for post

Three dimensions

If p=(p1, p2, p3), q=(q1, q2, q3) are two points in Euclidean space, the Euclidean distance is given by -

Image for post

n dimensions

If p=(p1, p2…pn) and q=(q1, q2…qn) are two points in Euclidean space, the Euclidean distance is given by -

Image for post

As you might have guessed by now, this formula looks a lot similar to the Pythagoras theorem formula. So, this is also called the Pythagoras Theorem.

#machine-learning #data-science #metrics

5 Most Commonly Used Distance Metrics in Machine Learning
1.20 GEEK