- Introduced by
- McInnes, L.; Healy, J.; Melville, J.
- Year
- 2018
- Type
- Nonlinear manifold-learning dimension reduction
What does it do?
UMAP (Uniform Manifold Approximation and Projection) is a nonlinear dimension-reduction method based on manifold learning.
It maps high-dimensional observations to a lower-dimensional embedding, most often two or three dimensions for plotting, which can then be passed to later analysis steps. The output dimension is a user setting. The method was introduced by McInnes, Healy and Melville in 2018.
The intuition behind the method
Many high-dimensional datasets are thought to lie near a lower-dimensional curved surface, or manifold, inside the full feature space. UMAP estimates the local neighbourhood of each point, builds a graph of those neighbourhoods, and then lays out the points in fewer dimensions so that the low-dimensional graph resembles the high-dimensional one. Because the method is nonlinear, it can unfold curved structure that a linear projection such as PCA would flatten. UMAP is usually compared with t-SNE and is often described as keeping more of the global layout; treat this as a tendency to check on your own data rather than a guarantee.
History
UMAP was introduced in 2018 by McInnes, Healy and Melville in an arXiv preprint (arXiv:1802.03426), building on manifold-learning ideas. It is presented as a nonlinear alternative to t-SNE for visualising high-dimensional data.
When to use it
Choose UMAP when you have continuous, high-dimensional data with enough observations to estimate local neighbourhoods reliably, and you want a low-dimensional picture of its neighbourhood structure for exploration or as a preprocessing step before classification or clustering. It suits cases where you expect curved, nonlinear structure that PCA would miss. Do not use it when you need a faithful linear map of variance directions, or when the sample is very small, since the neighbourhood structure cannot then be estimated reliably; in that case a linear method such as PCA is a useful point of comparison. If you need to make inferences about distances or group sizes, treat the UMAP output as descriptive only.
Limitations and considerations
- Distances between clusters in the embedding can be misleading, because cluster separation is not a measure of distance in the input space.
- The apparent structure depends on the n_neighbors and min_dist settings, so these must be tuned and their effect checked.
- The stochastic optimisation makes the output non-deterministic unless random_state is fixed.
- With small samples, the neighbourhood structure is estimated poorly and the plot can mislead; compare the result with a linear method such as PCA.
- The neighbour graph, and therefore the layout, depends on the distance metric and on feature scaling; these choices should be made deliberately and reported with the results.
- Coordinates from separate runs or different settings are not directly comparable axis by axis, because each embedding is a fitted transformation.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Captures nonlinear structure in the neighbourhood graph that a linear projection such as PCA cannot represent.
- The embedding is found by matching a graph-based objective, so the layout reflects which observations are neighbours rather than fixed linear axes.
- Produces two- or three-dimensional output that can be plotted directly.
- Designed with large datasets in mind and reported to scale more readily than t-SNE; runtime should still be checked on your own data.
Applications
- Plotting a two-dimensional layout of a high-dimensional feature matrix to check whether observations form visible groups.
- Exploratory inspection of data before choosing a formal clustering or classification model.
- Producing a reduced feature set for a downstream classifier, with the reduction fitted on training data only.
- Comparing the groupings produced across several n_neighbors and min_dist settings to see which structure persists.
How it works
How it works
UMAP first builds a weighted neighbourhood graph on the high-dimensional data, connecting each point to its nearest neighbours under the chosen distance metric. The n_neighbors setting fixes how many neighbours each point considers, which shifts the emphasis between local detail (smaller values) and broader structure (larger values). Because the neighbours depend on the distance metric and on how the features are scaled, these choices shape the graph and therefore the layout. This graph stands in for the manifold the data are assumed to lie on.
A low-dimensional layout is then optimised so that its own neighbourhood graph agrees with the high-dimensional one. The objective in the mechanics section is a cross-entropy between the two graph representations, G_high and G_low, minimised over the embedding Y; its exact form, including how edge weights are defined, is given in McInnes et al. (2018) and should be consulted for details. The min_dist setting controls how tightly points may pack together in the layout, which affects how visibly separated the resulting groups look.
Formula
Y = \arg\min_{Y} \; \text{cross-entropy}(G_{\text{high}}, G_{\text{low}})The output is a low-dimensional embedding, most often two or three dimensions, in which similar observations tend to lie close together, ready for plotting or for use in clustering or classification. The layout is mainly informative about which observations group together; distances between separated groups should not be read as precise quantities. The optimisation starts from a random initialisation, so a fixed random_state is needed to reproduce the same embedding. Coordinates from different runs or settings are not directly comparable axis by axis.
Common pitfalls
- Reading the gap between two clusters as a quantitative distance.
- Accepting the default n_neighbors and min_dist without checking how the layout changes across a range of values.
- Omitting random_state, so that a re-run gives a different picture that may be mistaken for a new finding.
- Running UMAP on a very small sample and interpreting the resulting plot.
- Treating a visible cluster as a confirmed group without checking it with an independent method.
Frequently asked questions
How is UMAP different from t-SNE?
Both are nonlinear methods for visualising high-dimensional data. UMAP is built on manifold-learning ideas and optimises a graph-matching objective. It is often reported to keep more of the global layout and to run faster on large datasets, but these comparisons should be checked on your own data rather than assumed.
Can I interpret distances between clusters in the plot?
Be cautious. The layout is designed to show which observations group together, but the distances between clusters can be misleading and should not be read as precise quantities.
Which hyperparameters matter most?
n_neighbors sets how many neighbours shape the local graph, which controls the balance between local and broader structure. min_dist controls how tightly points may pack together. Try a range of both values and fix random_state so the embedding can be reproduced.
What if I have very few observations?
With very few observations, the neighbourhood structure cannot be estimated reliably and the embedding can mislead. A linear method such as PCA is a useful comparison in that case.
Related methods
Sources
McInnes, L., Healy, J. & Melville, J. (2018). UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction. arXiv:1802.03426.
Open publication reference