liveBook · Manning

Manhattan distance

Manhattan distance is the sum of the absolute differences between corresponding coordinates of two points or vectors.

How 4 Manning books explain it

Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

Manhattan distance is the sum of the absolute differences between corresponding coordinates of two points.

How it is used
Guides A* search toward a goal in a four-direction maze.
How deep it goes
Defines the row-and-column calculation and implements it in Swift, then explains admissibility without a formal proof.
Examples
Uses Manhattan street blocks, maze locations, a grid figure, and a Swift distance function.
What you can do after
Build it from scratch as a Swift heuristic for four-direction A* maze search.

Read how Classic Computer Science Problems in Swift: Essential techniques for practicing programmers explains Manhattan distance →

Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

Manhattan distance is the sum of the absolute coordinate differences between two points.

How it is used
Creates geographical machine-learning features that represent proximity and urban travel patterns.
How deep it goes
Defines the metric, contrasts it with Euclidean distance, and applies it to coordinates and nearest-neighbor queries.
Examples
Uses Tokyo Airbnb coordinates, the Imperial Palace, and nearby transportation and facility categories.
What you can do after
Apply it via scikit-learn KDTree and coordinate transformations to create proximity features.

Read how Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI explains Manhattan distance →

Data Without Labels

Manhattan distance is the sum of absolute coordinate differences between two points, corresponding to movement along perpendicular axes.

How it is used
Uses absolute coordinate differences to measure similarity or distance between observations during clustering.
How deep it goes
Defines the grid-path formula, contrasts L1 with L2, and notes high-dimensional preference without detailing implementation.
Examples
Uses coordinate points, grid-like movement, and centroid or hierarchical clustering as application contexts.
What you can do after
Apply it as a distance metric when comparing clustering choices for a dataset.

Read how Data Without Labels explains Manhattan distance →

Outlier Detection in Python

Manhattan distance is the sum of the absolute coordinate-wise differences between two points.

How it is used
Uses coordinate-wise differences to compare records, including mixed datasets and some outlier-detection workflows.
How deep it goes
Defines the metric, compares its weighting with Euclidean distance, and demonstrates implementation; it stops short of a full detector.
Examples
Uses one-hot encoded color and weight rows, pairwise distance tables, and Python calls to manhattan_distances.
What you can do after
Apply it via scikit-learn to calculate distances between numeric or one-hot encoded records.

Read how Outlier Detection in Python explains Manhattan distance →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.