Quick Reference · uniform manifold approximation & projection

umap-learn cheat sheet

UMAP builds a fuzzy graph of your data's nearest neighbors, then optimizes a low-dimensional layout that keeps that graph's shape. Two dials do most of the work: n_neighbors (how local the view is) and min_dist (how tightly points pack). It follows the scikit-learn API — so it drops into pipelines, and can even transform new points onto a trained map.

data & setup graph · n_neighbors, metric layout · min_dist, spread fit / optimize embedding & new data pitfall most common

Distilled & cross-checked across: umap-learn.readthedocs.io (docs · API · parameter guide) · McInnes, Healy & Melville, 2018 (arXiv:1802.03426) · github.com/lmcinnes/umap · Coenen & Pearce — Understanding UMAP (Google PAIR) · Narayan et al., 2021 (densMAP) · scikit-learn

The two steps & the two dials that shape them
Data X n × d, high-dim scale features first Fuzzy graph kNN → fuzzy simplicial set topology of the data Optimize layout spectral init → cross-entropy force-directed SGD Embedding n × n_components reducer.embedding_ ◤ n_neighbors · metric ◤ min_dist · spread · n_components build graph embed result reducer.transform(X_new) — place new points on the trained map (sklearn API) reducer.inverse_transform(Y) — reconstruct a high-dim sample from a point in the map INPUT THE TWO-STEP FIT OUTPUT
01Install & Importonce per env
0260-Second Startthe daily loop
03The 4 core parameters80% of tuning
04n_neighbors · local ↔ globalthe graph dial
05min_dist · packingthe layout dial
06Metricsdistance in input space
07Embedding shapedims & init
08Fit, transform, reusescikit-learn API
09Supervised & semi-superviseduse your labels
10Clustering with UMAPreduce, then cluster
11Speed & scalebig & sparse data
12Variantsbeyond plain UMAP
13Plotting · umap.plotbuilt-in helpers
Recommended recipesensible starting point
!Reading the picturedon't over-read UMAP

How the pieces shape the map

Four ideas that decide what your embedding looks like — based on the UMAP parameter guide and Coenen & Pearce, “Understanding UMAP”.

the two steps

First build a fuzzy nearest-neighbor graph in high-D (set by n_neighbors); then optimize a low-D layout that keeps that graph's shape (set by min_dist).

1 · fuzzy graph 2 · optimized layout embed

n_neighbors: local ↔ global

Low values glue together small chains and miss the big picture; high values capture overall structure but blur fine detail.

low (2–5) chains default (15) clean clusters high (100+) global blob

min_dist: tight ↔ spread

Small min_dist lets clusters clump densely — better for clustering. Large values disperse points evenly — better for a clean overview.

min_dist = 0.0 min_dist = 0.8 dense clumps evenly dispersed

add new data: transform()

Fit once on a training set (grey), then transform unseen samples (colored) — each lands in the matching region. UMAP fits straight into sklearn Pipelines.

new samples → transform() → matching region grey = trained embedding

Worth memorizing

n_neighbors = local↔globaldefault 15; raise for global structure, lower for fine detail
min_dist = packing0.1 to view, 0.0 to cluster; keep it < spread
fit_transform → arraythe same result also lives on reducer.embedding_
transform() = sklearnembed new points; drop UMAP straight into Pipelines
scales in dimensionunlike t-SNE, set n_components high to feed downstream ML
global structureUMAP keeps the big picture better than t-SNE — but sizes still aren't literal
random_state trade-offreproducible, but forces single-threaded — slower
cosine for textnon-metric distances (cosine, correlation) are first-class
cluster in >2-Dreduce to ~10 dims + min_dist=0, then HDBSCAN — never cluster the 2-D view
numba warmupthe first fit compiles; later runs are fast