Euclidean distance
The distance between different points can quantify the similarity between two data points and is extensively used in unsupervised machine learning techniques, such as clustering. Euclidean distance is the most common and simple distance measure used. It is calculated by measuring the shortest distance between two data points in multidimensional space. For example, let's consider two points, A(1,1) and B(4,4), in a two -dimensional space, as shown in the following plot:
![Chart Description automatically generated](https://static.packt-cdn.com/products/9781803247762/graphics/media/file80.png)
To calculate the distance between A and B—that is d(A,B), we can use the following Pythagorean formula:
![A picture containing shape Description automatically generated](https://static.packt-cdn.com/products/9781803247762/graphics/media/file81.png)
Note that this calculation is for a two-dimensional problem space. For an n-dimensional problem space, we can calculate the distance between two points A and B as follows:
![A picture containing shape Description automatically generated](https://static.packt-cdn.com/products/9781803247762/graphics/media/file82.png)