What is Euclidean distance in terms of machine learning?
Euclidean distance is the straight-line distance between two samples \(\mathbf{p}\) and \(\mathbf{q}\) in an \(n\)-dimensional feature space:
\[d(\mathbf{p},\mathbf{q}) = \sqrt{\sum_{i=1}^{n}(q_i-p_i)^2}.\]We subtract the samples’ values for each feature, square the differences, add them, and take the square root. For example, the distance between \((1,2)\) and \((4,6)\) is \(\sqrt{3^2+4^2}=5\).
In two dimensions, we can picture it as the line connecting the two points:

Euclidean distance is commonly used in K-nearest neighbors and K-means to compare samples. Hierarchical clustering can also use it to compute point-to-point distances before combining them into cluster distances through a linkage rule.
Feature scales matter. A feature measured in thousands can dominate another measured in fractions, even when both are useful. Standardization can help when the features should contribute on comparable scales.