UMAP
UMAP is a fast nonlinear embedding that preserves local and some global structure, useful for both visualization and features.
Manifold learning at scale
Uniform manifold approximation and projection (UMAP) reduces dimensionality by assuming the data lies on a manifold and building a graph that captures its topology, then optimizing a low-dimensional layout that keeps that graph's structure. It is faster than t-SNE, scales to large datasets, and tends to retain more global structure.
Key parameters
- n_neighbors: small values emphasize local detail, large values emphasize global shape.
- min_dist: how tightly points may pack; small values make dense clusters.
- n_components: output dimensionality, 2 or 3 for plots, more for features.
- metric: the distance used to build the neighbor graph.
import umap
reducer = umap.UMAP(n_neighbors=15, min_dist=0.1)
Z = reducer.fit_transform(X)
UMAP versus t-SNE
Both are nonlinear and neighbor-based. UMAP usually runs faster, handles more points, and preserves the broad arrangement of clusters better, while t-SNE can produce very clean local separations. As with t-SNE, treat exact inter-cluster distances with caution, and try several settings.
Beyond plots
Unlike t-SNE, UMAP can transform new points with a learned mapping, so its low-dimensional coordinates can feed a downstream supervised model, not just a figure. It combines well with PCA as a linear pre-reduction. For genuinely linear compression where components must be interpretable, PCA remains the right tool.
UMAP rests on ideas from topology: it models the data as a fuzzy simplicial set, a weighted graph of local neighborhoods, then finds a low-dimensional graph whose structure matches as closely as possible under a cross-entropy objective. You do not need the mathematics to use it, but it explains why UMAP preserves connectivity well and why its layouts, while informative about neighborhoods, should not be read as a faithful map of absolute distances.