When would you choose Manhattan distance over Euclidean distance in a k-NN model?
answer
- one family, exponent p
- square versus absolute aggregation
- one huge gap or many small ones
- unit ball: diamond, circle, square
- blocks, not straight lines
basics
~10 sManhattan adds absolute per-feature gaps instead of squaring them, so one badly mismatched feature is less overwhelming, and it matches domains where movement is axis-constrained, such as travel along a city grid.
solid answer
~40 sBoth are members of the Minkowski family, `d_p = (sum_j |x_j - y_j|^p)^(1/p)`: Manhattan is `p = 1`, Euclidean is `p = 2`. Squaring means a single large gap in one feature dominates the total, so Euclidean is the more outlier-sensitive of the two; Manhattan lets each feature contribute linearly, which keeps one wild coordinate from deciding the whole neighbour list. Manhattan is also the physically correct metric when movement is axis-constrained — a courier in a strict street grid travels blocks, so the north-south plus east-west gap is the real travel distance, not the straight line. There is also evidence that lower `p` degrades more gracefully as the number of features grows. In practice, treat `p` as a hyperparameter and tune it alongside k — after scaling, which both metrics require.
go deeper
Know the two formulas by shape: Manhattan adds absolute differences, Euclidean adds squared differences and takes a square root. Be able to say that squaring makes one big mismatch count for more.
Explain the Minkowski parameter that links them, what p = 1, 2 and infinity each mean, and give one concrete case where a single large per-feature gap flips the ranking between them.
Argue the choice from data properties — heavy-tailed columns, axis-aligned domains, wide feature sets — and describe how you would settle it empirically instead of by folklore, with scaling fixed first.
Frame metric choice as part of the model specification rather than a knob: decide when domain cost structure should dictate it, and when the effort is better spent on features than on searching over p.
## One family, one dial Manhattan and Euclidean distance are not two unrelated ideas; they are two settings of one parameter. The Minkowski distance of order `p` between records `x` and `y` is ``` d_p(x, y) = ( sum_j |x_j - y_j|^p ) ^ (1/p) ``` with `p = 1` giving Manhattan (also called city-block or taxicab) distance, `p = 2` giving Euclidean, and `p` growing without bound giving Chebyshev distance, `max_j |x_j - y_j|`, where the single worst-matching feature decides everything. For any `p >= 1` this is a genuine metric: non-negative, symmetric, zero only for identical points, and obeying the triangle inequality. Fractional orders below 1 do not satisfy the triangle inequality and are dissimilarity scores rather than metrics. ## How the exponent changes the answer The exponent decides how per-feature disagreements are aggregated. Consider two candidate neighbours of a query, both on standardised features: - Candidate A differs by 3 in one feature and 0 in nine others. - Candidate B differs by 1 in each of the same ten features. Under Manhattan, A scores 3 and B scores 10, so A is much closer. Under Euclidean, A scores `sqrt(9) = 3` and B scores `sqrt(10) = 3.16` — nearly a tie. Squaring inflates the one big gap until it is worth almost as much as ten moderate ones. Push to Chebyshev and A scores 3, B scores 1, and B wins outright. That is the whole tradeoff in miniature. **Euclidean punishes a single large mismatch hardest; Manhattan spreads the vote across features; Chebyshev hands the decision to the worst feature.** If your data has heavy-tailed features, or a handful of columns that are occasionally garbage, Manhattan is the more forgiving aggregation, in the same spirit that an absolute-error loss is more robust than a squared-error loss. ## The geometric picture The set of points at distance 1 from the origin — the unit ball — makes the difference visible. Under Euclidean it is a circle: every direction is treated alike, and the metric is unchanged if you rotate the coordinate system. Under Manhattan it is a diamond with corners on the axes; under Chebyshev it is a square. Manhattan and Chebyshev are therefore **axis-aligned** metrics: rotating the features changes the distances. That is a drawback when the axes are arbitrary, and exactly the right property when the axes mean something physically. ## When the domain picks the metric for you A courier moving through a strict street grid cannot cut diagonally through buildings. Travelling from one address that is four blocks east and three blocks north of another costs seven blocks, not the five that the straight line suggests. Here Manhattan is not a robustness heuristic, it is the literal cost, and using Euclidean would systematically understate every delivery. Any domain where movement or cost accrues one axis at a time — grid layouts, warehouse aisles, edits applied one field at a time — has the same shape. ## Dimensionality, briefly There is published evidence that as the number of features grows, distances computed with lower `p` retain more contrast between the nearest and the farthest point than higher `p` does, which is one reason `p = 1` is sometimes preferred on wide feature sets. Treat it as a mild prior worth testing, not a law: the deeper behaviour of neighbourhoods in high dimensions is a topic of its own. ## What does not change Every Minkowski order sums per-feature gaps in the features' own units, so all of them require the features to be on a common scale first. Changing `p` on unscaled data changes only which oversized feature wins, not whether one does. Both are also equally blind to correlation between features: two heavily correlated columns effectively count that information twice, regardless of `p`. ## How to decide in practice Unless the domain dictates the metric, do not agonise. Put `p` in the hyperparameter search next to k, try 1 and 2 — and Chebyshev if a worst-feature rule is plausible — and let cross-validated performance choose. The gains are usually modest compared with getting the scaling and the feature set right, which is why an interviewer asking this question is usually checking that you understand *why* the choice exists rather than expecting a fixed answer. The defensible reply names the aggregation difference, the axis-alignment property, and the one domain fact — grid-like movement — that overrides the tuning.
- What does Minkowski distance become as p grows without bound?Chebyshev distance, `max_j |x_j - y_j|` — the single largest per-feature gap, with every other feature ignored. It is the right choice when a record is unacceptable if it is far off on *any* one attribute, such as a tolerance check where the worst dimension governs. It sits at the opposite end of the family from Manhattan, which lets every feature vote.
- Is p something you should tune, or decide on principle?Both, in that order. If the domain has axis-constrained cost — grid travel, per-field edits — principle decides and you use Manhattan. Otherwise put p in the same cross-validated search as k and let the data pick between 1 and 2. Tune it after scaling, never before: on unscaled features you are only choosing which oversized column wins.
- Does Manhattan distance still satisfy the triangle inequality?Yes. Every Minkowski order with `p >= 1` is a true metric, so `d(x, z) <= d(x, y) + d(y, z)` holds for Manhattan, Euclidean and Chebyshev alike. That matters because search structures that prune candidate regions rely on the triangle inequality to guarantee they are not discarding a genuine nearest neighbour. Fractional orders below 1 break it.
saying these in an interview costs you the question
- Treats Manhattan and Euclidean as unrelated formulas, not one family
- Says Manhattan is simply faster to compute, and stops there
- Claims Euclidean is more robust to outlying feature values
- Thinks changing p removes the need to scale features
- Assumes p tending to infinity averages the feature gaps