liveBook · Manning

Euclidean distance

As explained in Data Without Labels

Euclidean distance is the straight-line distance between points in a coordinate space, computed as the square root of the summed squared coordinate differences.

Euclidean distance measures the straight-line distance between two points. In clustering, a smaller distance can indicate greater similarity: a point close to a cluster centroid is more similar to that centroid than a point farther away. section 2.3

For P₁ = (x₁, y₁) and P₂ = (x₂, y₂), distance = √[(x₂ − x₁)² + (y₂ − y₁)²]. Subtract corresponding coordinates, square the differences, add them, and take the square root. section 2.3

Figure 2.5 Euclidean distance, Chebyshev distance, Manhattan distance, and cosine distance are the primary distance metrics used. Note how the distance is different for two points using these metrics. In Euclidean distance, the direct distance is measured between two points, as shown by the first figure on the left.
figure

Compare the direct path measured by Euclidean distance with the paths or measurements used by other distance metrics. section 2.3

Choose the metric for the data and clustering task, rather than treating the common default as automatic:

  • In centroid-based clustering, distances between points and centroids guide similarity; k-means most often uses Euclidean distance. section 2.3 section 2.3.4
  • In hierarchical clustering, the distance metric and linkage criterion are separate choices. Single, complete, and group-average linkage use different point-to-point distances to define distance between clusters. section 2.4.2
  • With many dimensions, Euclidean distance can become less useful or harder to compute; Manhattan distance is suggested as an alternative. Different metrics can also produce different clusters. section 2.3 section 2.7

Checking distances in a DBSCAN workflow

Standardize the data, calculate each point’s nearest-neighbor distance, then sort and plot those distances to help choose ε. Inspect the resulting clusters after fitting DBSCAN: its distance metric matters, and changing ε or minPts can substantially change the result. The shown workflow does not explicitly set a distance metric. section 2.5.2

How Data Without Labels covers it

How deep it goes
Defines straight-line distance and gives a two-coordinate formula; defers detailed L2-norm treatment and high-dimensionality discussion.
Examples
Uses two coordinate points, a visual comparison of distance metrics, and a DBSCAN nearest-neighbor-distance plot.
What it assumes
Assumes coordinate pairs and numeric data; points to separate explanations of L1 and L2 norms.
What you can do after
Evaluate/understand it when interpreting centroid proximity and comparing distance choices for clustering.
How it connects
Connects centroid-based clustering, k-means, hierarchical linkage, DBSCAN, Manhattan distance, and the curse of dimensionality.

Also explained in

Compare how 8 books explain Euclidean distance →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Without Labels. The section links point to the parts of the book it draws on.