UMAP Deep Dive
Picking up where t-SNE left off
t-SNE popularized high-dimensional visualization but came with real costs: it scales poorly to large datasets, its global layout is unreliable, and results shift between runs. UMAP (Uniform Manifold Approximation and Projection), introduced by Leland McInnes, John Healy, and James Melville in 2018, was built on a different mathematical foundation — topology and manifold theory rather than purely probabilistic neighbor matching — and it addresses several of t-SNE's weak points directly while remaining fast enough for datasets with millions of points.
The core idea: approximating a manifold
UMAP assumes the high-dimensional data lies on (or near) a lower-dimensional manifold embedded in that high-dimensional space — the classic 'Swiss roll' intuition: a 2D sheet that's been crumpled into 3D, where straight-line distance misleads but distance-along-the-sheet doesn't. UMAP's two-stage process:
Stage 1 — Build a weighted graph approximating the manifold. For each point, connect it to its nearest neighbors, with edge weights derived from a fuzzy topological framework that accounts for varying local density (a point in a dense region gets different neighbor weighting than one in a sparse region). This produces a single graph meant to approximate the true underlying manifold structure.
Stage 2 — Lay out a low-dimensional graph that matches it. Initialize a low-dimensional embedding (often via spectral embedding, which gives a much better starting point than t-SNE's typical random initialization) and then optimize it via stochastic gradient descent so the low-dimensional graph's structure matches the high-dimensional graph, using cross-entropy between the two as the optimization target rather than t-SNE's KL divergence.
Note
Why UMAP preserves global structure better
t-SNE's objective essentially only rewards getting local neighbors right, so the relative placement of distant clusters is close to arbitrary. UMAP's graph-based construction and its typically better (spectral) initialization give it a structural advantage: the optimization has to respect a connected graph representation of the whole dataset from the start, not just pairwise local probabilities. In practice this means inter-cluster distances and relative cluster positions in a UMAP plot are more trustworthy than in a t-SNE plot — though still not as reliable as a linear method like PCA, since UMAP is still fundamentally optimizing nonlinear local relationships first.
t-SNE vs. UMAP head-to-head
| Property | t-SNE | UMAP |
|---|---|---|
| Mathematical basis | Probabilistic neighbor matching (KL divergence) | Fuzzy topology / manifold approximation (cross-entropy) |
| Global structure fidelity | Weak, often misleading | Better, though still imperfect |
| Speed at scale | Slow, struggles past ~50k points | Much faster, handles millions of points |
| Embedding new/unseen points | Not supported natively | Supported via .transform() |
| Typical initialization | Random (or PCA, optionally) | Spectral embedding by default |
| Sensitivity to key hyperparameter | High sensitivity to perplexity | High sensitivity to n_neighbors and min_dist |
PCA vs. t-SNE vs. UMAP — choosing the right tool
| Use case | Best choice | Why |
|---|---|---|
| Quick linear sanity check before anything else | PCA | Fast, deterministic, interpretable axes (explained variance) |
| Exploring fine local cluster structure, dataset is small | t-SNE | Strong local structure preservation, well understood, mature tooling |
| Visualizing large embedding sets (100k+ points) | UMAP | Scales far better, supports incremental new-point embedding |
| Need to embed new data without recomputation | UMAP | Has a real transform function; t-SNE does not |
| Need the most trustworthy global layout | PCA (as a complement to either) | Linear methods never distort global distances by construction |
Note
What's next
Both t-SNE and UMAP exist to make unlabeled, high-dimensional structure visible to a human eye — the same underlying goal as clustering, just aimed at perception rather than partitioning. Together with K-Means, Spectral Clustering, and Mean Shift, you now have a broad toolkit for making sense of data with no labels at all, from partitioning it into groups to simply looking at its shape.
I build these systems professionally.
Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.