UMAP
UMAP (Uniform Manifold Approximation and Projection) is a nonlinear dimensionality reduction algorithm grounded in Riemannian geometry and algebraic topology that constructs a fuzzy topological representation of high-dimensional data and optimizes a low-dimensional embedding to match it. It matters in modern AI and ML as the go-to technique for visualizing embeddings from large neural networks, single-cell genomics, and NLP pipelines — dramatically faster than t-SNE while better preserving global structure. The counterintuitive fact: UMAP's apparent "clusters" in 2D projections can be artifacts of its hyperparameters rather than true structure in the data, making interpretation a genuine statistical hazard.
UMAP works by assuming data lies on a low-dimensional manifold embedded in high-dimensional space, building a weighted neighborhood graph that encodes local geometry, and then finding a low-dimensional layout that preserves that graph structure as faithfully as possible. The "aha moment" is that UMAP never thinks about distances in the ambient ℝⁿ — it thinks about fuzzy set membership: how likely is point B to be "in the neighborhood" of point A given the local density around A? By normalizing distances relative to each point's local neighborhood, UMAP handles non-uniform density elegantly, unlike methods that treat all distances globally.
How It Works
UMAP proceeds in two major phases: graph construction (high-dimensional) and graph layout optimization (low-dimensional).
Phase 1: Constructing the High-Dimensional Fuzzy Graph
For each point , UMAP finds its nearest neighbors and defines a local metric that normalizes for density. Let be the distance to 's nearest neighbor (the local connectivity correction) and be a bandwidth parameter chosen so the fuzzy membership function sums to . The directed edge weight (fuzzy set membership) from to is:
Explanation: This gives the probability that is "in the neighborhood" of , with the local offset ensuring at least one neighbor always has weight 1 regardless of the point's surrounding density.
Symbol guide:
- : distance between points and in the high-dimensional space
- : distance from to its nearest neighbor (ensures local connectivity)
- : per-point bandwidth found by binary search to satisfy the soft normalization constraint
Because in general, UMAP symmetrizes to form undirected edge weights using the fuzzy union:
Explanation: This is the probability that at least one of the two directed edges exists — the standard union rule for independent fuzzy sets — producing a symmetric affinity matrix.
Phase 2: Low-Dimensional Graph Layout
UMAP places each point into (typically or ), then optimizes positions so the low-dimensional graph matches the high-dimensional one. Low-dimensional affinities are defined using a differentiable approximation to a Student--like kernel with trainable parameters and (fit to a smooth curve):
Explanation: This is the probability that and are connected in the low-dimensional embedding — its heavy tail (controlled by ) allows moderately distant points to remain separated without creating artificially tight clusters.
Symbol guide:
- : low-dimensional coordinates being optimized
- : hyperparameters fit by nonlinear least-squares to approximate a specific smooth curve; default values in the reference implementation are ,
The objective is the binary cross-entropy between high-dimensional and low-dimensional affinities — the fuzzy set cross-entropy:
Explanation: This penalizes both false attractions (putting distant pairs too close in 2D) and false repulsions (pushing nearby pairs too far apart), balancing local preservation against global separation. Because computing all pairs is , UMAP approximates the second term using negative sampling: for each edge with weight , it draws random "negative" pairs and repels them. The gradient update for an attractive force between and has closed form:
Explanation: The attractive gradient pulls toward proportionally to how much their current low-dimensional distance exceeds what the embedding kernel predicts — vanishing when they are already close. Optimization runs via stochastic gradient descent with a decaying learning rate, typically for 200–500 epochs.
Leland McInnes is a mathematician at the Tutte Institute for Mathematics and Computing in Ottawa, with expertise in topological data analysis and computational mathematics. He published UMAP in 2018 with John Healy and James Melville, grounding what had been largely heuristic dimensionality-reduction practice in rigorous algebraic topology and Riemannian geometry. Surprisingly, the original UMAP preprint was posted on arXiv without peer review and spread virally through the bioinformatics and machine learning communities before any formal publication, becoming one of the most-cited arXiv papers of 2018.
Intuition
Imagine you are a cartographer tasked with drawing a 2D map of a social network where people are clustered in cities, but the cities are scattered across a continent. Your first step is not to measure global distances between cities — it's to ask each person: "Who are your ten closest friends, and roughly how far away are they?" In a dense city, "close friend" might mean someone two blocks away; in a rural area, it might mean someone twenty miles away. UMAP does exactly this: it measures neighborhood relationships relative to local density, so that "close" means something consistent everywhere on the manifold, regardless of whether that region of data is crowded or sparse. Once you have everyone's local friendship list (the fuzzy graph), your second task is to draw the map (the 2D embedding) so that friends remain near each other on paper. You pull connected nodes together like rubber bands (attractive forces) and nudge disconnected nodes apart like magnets (repulsive forces), iterating until the map stabilizes. The result is a layout where tight friend-groups collapse into visible clusters — but the distances between those clusters on paper depend heavily on how strong your repulsive magnets were, not purely on how dissimilar the groups actually are. That is why UMAP excels at revealing local cluster structure but should not be used to judge global topology without caution.
Historical Development
Origins · 1 minhow this was discovered
Why It Matters
Prerequisites
What This Leads To
See Also
t-SNE · Principal Component Analysis · Autoencoders · Manifold Learning · Topological Data Analysis