How UMAP builds a locally scaled fuzzy neighbour graph, combines memberships and optimises a map—and why its islands, distances and densities need careful interpretation.
UMAP
UMAP (Uniform Manifold Approximation and Projection) is a nonlinear dimensionality-reduction method that builds a weighted neighbourhood graph and finds a smaller set of coordinates representing that graph. A quant researcher might use it to explore similarities among assets described by many features. An island on the resulting map suggests observations to investigate; it does not establish an asset class, a market regime or a trading signal.
The essential distinction is between constructing the relationships and drawing them. The first stage depends on the original features and distance definition. The second optimises a layout, usually in two dimensions for visualisation. Neither stage guarantees that a financial dataset lies on a stable low-dimensional manifold. The original paper, §3, explains this graph-based view and its assumptions.
Each observation gets a local ruler
Start with feature vectors xi and a chosen dissimilarity d. UMAP finds a neighbourhood around each observation, using nearest neighbours. A single distance threshold would behave differently in dense and sparse regions, so it adapts the scale locally.
For the basic construction with local connectivity one, ρi is the distance from observation i to its nearest distinct, positive-distance neighbour. A positive bandwidth σi controls how quickly membership decays beyond this offset. For a retained neighbour j, its directed membership is
vi→j=exp(−σimax{0,d(xi,xj)−ρi}).
The bandwidth is selected to match a target smooth neighbourhood size, rather than being held equal across observations. Membership is one up to the local offset and decays thereafter. Implementation details handle duplicates and other local-connectivity settings; the expression describes the basic mechanism. See McInnes, Healy and Melville, §3.1 and the official local-scaling explanation.
These memberships lie between zero and one, but they are neither distances nor calibrated probabilities of an economic event. A row need not sum to one. Even when the original distance is symmetric, different local rulers can give vi→j=vj→i.
A checked edge calculation
Suppose the directed memberships for a particular pair have already been computed:
vi→j=0.8,vj→i=0.5.
Under the pure fuzzy-union rule, the symmetric edge strength is
wij=vi→j+vj→i−vi→jvj→i=0.8+0.5−0.4=0.9.
Equivalently, wij=1−(1−0.8)(1−0.5)=0.9. The result is stronger than either input without exceeding one. Taking the arithmetic mean would give 0.65, a different operation. The official graph-construction explanation describes this union; the current API also supports mixtures of union and intersection through set_op_mix_ratio, whose default is pure union.
Illustrative directed memberships from i to j of 0.8 and from j to i of 0.5 merge into one undirected edge of strength 0.9. The calculation is 0.8 plus 0.5 minus their product 0.4. Node positions are schematic and are not fitted UMAP coordinates.
Original schematic of one edge calculation. All weights are dimensionless; node positions carry no distance information. This is not a fitted embedding.
No feature vectors, neighbour search, fitted bandwidths or optimised coordinates are supplied here. The calculation checks symmetrisation alone. A membership of 0.9 does not mean a 90% chance that two assets belong to the same sector, nor a 90% chance that their returns will move together.
The graph still needs a layout
UMAP then adjusts low-dimensional positions to make their induced fuzzy relationships resemble the input graph. Strong graph edges encourage attraction, while sampled repulsive updates help prevent collapse. This is a nonconvex optimisation, not a solution that preserves every original distance. The paper’s graph-layout section describes the cross-entropy motivation and sampled repulsion.
Three choices materially change what the reader sees, as documented in the official parameter guide:
n_neighbors sets the neighbourhood scale. Smaller values emphasise fine local relationships; larger values incorporate broader relationships, potentially smoothing away detail. It is not a requested cluster count.
min_dist, together with spread, shapes how tightly the map packs neighbouring points. A smaller setting can make islands look denser and more separated. It is a layout control, not an observed economic threshold or a hard guarantee on every pairwise separation.
metric defines similarity in the input space. Changing from Euclidean to cosine distance changes the question asked of the data; an attractive picture cannot decide which question is economically useful.
UMAP uses randomness in approximation and optimisation. Inspect several seeds and settings before interpreting a pattern. For reproducing a selected run, record the seed, preprocessing, input order, package versions and execution settings. The current reproducibility guide explains that setting random_state disables parallel optimisation that cannot be reproduced explicitly, with a possible performance cost. Reproducing one map is separate from showing that the conclusion survives other runs.
What a financial map can support
Suppose each point is an asset, described by trailing volatility, factor exposures and liquidity measures. The feature window, data availability and scaling determine its neighbours. With Euclidean distance, a feature’s numerical units can dominate unless the preprocessing deliberately accounts for them. Robust feature scaling is one possible design choice, not an automatic cure for a poor feature definition.
Check neighbours and apparent groups in the original features. A plotted island’s area does not recover its original density; the gap between islands is not a calibrated measure of economic dissimilarity. UMAP can create apparent breaks within a group. The authors’ clustering guide explicitly warns about density distortion and false tears. Applying a clustering algorithm to the coordinates therefore creates a further model to evaluate, not confirmation supplied by the picture.
For forecasting, split by the information available at each date before learning scaling or the embedding. Refit both inside each training fold, and tune settings using training and validation periods. Including later observations in a historical embedding can introduce look-ahead bias even when target labels are absent. This applies the official training-only preprocessing rule to a financial time sequence.
The umap-learn implementation can place unseen observations into an existing fitted space with transform; a fresh fit creates a different coordinate system. The official transform tutorial assumes comparable training and testing distributions. Availability of a transform does not establish reliability under a new market distribution. If the coordinates feed a predictive model, assess the complete pipeline on later held-out observations and compare against simpler representations.
UMAP beside PCA and t-SNE
Method
What its representation targets
Useful distinction
PCA
Linear directions retaining the most variance in the chosen feature scaling
Provides component loadings and explained-variance ratios; does not generally unfold curved structure.
Agreement between high- and low-dimensional neighbourhood affinities
Usually used for visual exploration; its standard formulation jointly fits the supplied observations.
UMAP
A low-dimensional representation of a locally scaled fuzzy graph
Can support visualisation or a fitted transformation for downstream modelling; requires validation of that use.
PCA’s target is described in the official decomposition guide. None of these objectives guarantees preservation of the feature most relevant to a future financial target. More separated islands do not establish a superior representation.