Euclidean Distance
Euclidean distance is the straight-line separation between two points, a generalization of the Pythagorean theorem. We explain its use as a similarity measure in machine learning (k-NN, k-means), two important cautions—scale and dimensionality—and its relation to other metrics.
The Euclidean distance between two points is the length of the straight segment joining them: the ordinary “straight-line” distance. It is computed, in any number of dimensions, by taking the difference between the two points in each coordinate, squaring it, summing all those differences and taking the square root of the total. It is a direct generalization of the Pythagorean theorem.
What it is for in machine learning
In machine learning, each sample is represented as a point in a feature space, and Euclidean distance measures its similarity: less distance means more similarity. It underpins algorithms such as k-nearest neighbors, which classify a sample by its nearest points, or k-means, which clusters by assigning each point to the nearest group center.
Two important cautions
Two nuances are worth keeping in mind. The first is sensitivity to scale: if one variable has a much larger numeric range than the others, it dominates the calculation and the rest barely count; that is why it is standard practice to normalize or standardize the variables before measuring distances. The second is the curse of dimensionality: in high-dimensional spaces distances tend to become equal to one another and lose their power to discriminate, which degrades proximity-based algorithms.
Other metrics
Euclidean distance is not the only one. The Manhattan distance sums the absolute values of the differences and tends to behave better on sparse or high-dimensional data. And cosine similarity measures the angle between two vectors rather than their distance, so it ignores magnitude; it is preferred for comparing text embeddings, where direction matters and size does not.
This article was produced with artificial intelligence under human editorial oversight.