Manhattan Distance
When an unsupervised model asks “how far apart are these two data points?”, the answer depends on what kind of movement you allow. Manhattan distance measures distance by adding up the absolute difference in each feature, like traveling through a city grid where you move block by block instead of cutting diagonally across buildings.
How it works
For two points, Manhattan distance is the sum of coordinate-wise gaps: if one customer is at (age, income) = (30, 50) and another is at (35, 70), the distance is |30-35| + |50-70| = 5 + 20 = 25. This is also called L1 distance or city-block distance. Unlike Euclidean distance, which squares differences and emphasizes large gaps, Manhattan distance treats each feature’s contribution linearly. That makes it less sensitive to a single feature having one unusually large difference.
Why it matters in unsupervised learning
Distance is the engine behind many unsupervised methods, so the choice changes the structure a model sees.
- In clustering, it affects which points are considered neighbors or cluster members.
- In anomaly detection, it changes which observations look unusually far from the rest.
- In high-dimensional sparse data, such as document word counts or user activity vectors, Manhattan distance can be more interpretable than Euclidean distance because it reflects total feature-by-feature mismatch.
Practical use
You’ll encounter Manhattan distance in tools like scikit-learn, where it appears as metric="manhattan" or metric="l1" in nearest-neighbor methods, clustering workflows, and distance computations such as sklearn.metrics.pairwise.manhattan_distances. It works best when features are properly scaled; otherwise, a variable like income can dominate a variable like age simply because its numeric range is larger. In customer segmentation, transaction analysis, and text data, Manhattan distance gives a clean way to compare records by total absolute difference rather than straight-line geometry.
Manhattan Distance is a distance measure that computes the dissimilarity between two points as the sum of the absolute differences across their features. Also called L1 distance or city-block distance, it measures how far points are apart when movement is constrained along coordinate axes. It matters in unsupervised learning because clustering, nearest-neighbor search, and anomaly detection depend on the distance definition, and Manhattan distance is especially useful when feature-wise deviations should add linearly.
Think of walking through a city laid out like a grid, such as Manhattan. You usually can’t go straight through buildings, so you travel block by block: three streets over, then two avenues up. Manhattan Distance measures distance that same way.
In AI, it’s a way to say how different two things are by adding up the step-by-step differences across their features, or measurable traits. Instead of asking “as the crow flies,” it asks “how far if you must follow the streets?” This matters in unsupervised learning, where AI groups similar items without labels. Sometimes block-by-block difference matches real life better than straight-line distance, especially when each feature adds its own separate amount of change.