UMAP
UMAP — Fast manifold embedding preserving local and some global structure.
UMAP is a faster cousin of t-SNE that preserves more of the global structure. It builds a graph of neighbors and lays it out in 2D, revealing clusters while keeping their arrangement more faithful.
- Cluster 0
- Cluster 1
- Cluster 2
- k-NN graph edge
Same data, two embeddings running on the same clock. UMAP converges fast and tends to keep clusters that are close in the data close in the layout; t-SNE spends its early iterations under exaggeration and cares only about local neighbourhoods. (This is a simplified, in-spirit UMAP for teaching — not the full fuzzy-simplicial optimizer.)
UMAP controls
The idea in plain words
UMAP is a faster cousin of t-SNE. It builds a graph connecting each point to its nearest neighbors, then lays that graph out in 2-D with attractive forces along edges and repulsion elsewhere. Run both on the same data and the contrast is the lesson.
UMAP tends to preserve more global structure and converges faster, so clusters that are related in the data often stay closer in the layout. Very small n_neighbors fragments the manifold into disconnected islands.
Now, the math
UMAP optimizes a low-D layout to match a fuzzy neighbor graph, balancing two forces:
- graph connectivity — small values emphasize local, fine structure.
- how tightly points may pack in the layout.
▸ Show the derivation
UMAP models neighborhoods as a fuzzy simplicial set and minimizes a cross-entropy between the high-D and low-D graphs. Fewer neighbors means a sparser graph, so weakly-connected regions drift apart into islands. (This build is a simplified force-directed stand-in for teaching, not the full optimizer.)
Trace it by hand
One edge of UMAP's fuzzy neighbor graph, for a pair A, B at distance 2. A's nearest neighbor is at distance 1 (rho A = 1), B's is at distance 1.5 (rho B = 1.5), and we fix sigma = 1 for both (real UMAP tunes sigma per point from n neighbors). Values rounded to 4 decimal places. The site's interactive uses a simplified force layout; these are the standard UMAP weight formulas.
Step 1 — the directed weight from A's point of view
Distances are measured beyond rho, the gap to the nearest neighbor — so every point's local scale is recentered before weighting.
Step 2 — the same edge from B's point of view
The two directed views disagree: the edge matters more to B than to A. UMAP must reconcile them.
Step 3 — fuzzy union: a probabilistic OR
This is the probability that at least one of the two directed edges exists — an edge survives if either endpoint believes in it.
Step 4 — nearest neighbors always get weight 1
Subtracting rho guarantees every point is fully connected to its nearest neighbor, so no point is stranded — the union then keeps that 1.
What just happened: Two directed opinions about the same pair, 0.3679 and 0.6065, fused into one edge of strength 0.7513 by the fuzzy OR. That single number then acts as the attraction strength when the layout is optimized — edges near 1 pull hard, weak edges barely pull, and non-edges only repel.
Now Break It
Try this: Very small n_neighbors fragments the manifold into disconnected islands.
Control: n_neighbors slider (set very low)
What happens: Fragmented manifold! Too few neighbors breaks the structure into disconnected islands.
Where umap is used
UMAP is a manifold learning method that embeds high-dimensional data into a low-dimensional map, and it has grown popular because it is fast, scales to large datasets, and tends to retain more of the global layout than t-SNE. Practitioners use it to visualize millions of single cells in biology, to explore embeddings from language and vision models, and to lay out large collections of documents or images so related items form navigable regions. Unlike purely visual methods, UMAP can also serve as a general dimensionality reduction step: it produces a reusable transformation, so you can project new, unseen points into an existing embedding and even reduce to more than two dimensions as a preprocessing stage before clustering or classification.
A widespread misconception is that UMAP faithfully preserves global distances; it captures local structure well and more global structure than t-SNE, but the spacing between distant clusters still should not be read as a precise measure of dissimilarity. Its two main knobs shape the result strongly: n_neighbors trades local detail against broader structure, and min_dist controls how tightly points pack, so tuning them changes the visual story considerably. Like t-SNE, UMAP is stochastic and can produce apparent clusters or gaps that are partly artifacts of the parameters, so conclusions should be checked at several settings. It is a powerful embedding tool, but the geometry of its output is qualitative, not a metric to be measured off the plot.
Frequently asked questions
How is UMAP different from t-SNE?
What do n_neighbors and min_dist control?
Can UMAP preserve global structure?
Can I project new data points into an existing UMAP embedding?
Is UMAP deterministic?
Written & reviewed by the ML Visualization team · Last updated .