Visual explainer
t-SNE & UMAP
Trace Gaussian affinities, fuzzy graph edges and map forces, then see why a readable two-dimensional map cannot preserve every distance.
t-SNE and UMAP build low-dimensional maps using neighborhood relationships. A map can reveal useful structure while distorting distances. It does not certify class boundaries or preserve every relationship.
Our synthetic samples are A=(0,0,0), B=(0,0,1), C=(0,0,2), D=(0,0,3). The left ruler shows their third coordinate; the right view drops that coordinate. The concentric rings indicate four coincident samples, not four different radii. This selected projection loses everything distinguishing them; a suitable linear projection onto z would preserve them exactly.
Turn Distances Into Affinities
The t-SNE paper constructs conditional Gaussian affinities, symmetrizes them, then matches normalized Student-t map affinities by minimizing KL divergence. Bandwidth controls the input neighborhoods; heavy tails help address crowding. Optimization can find different local solutions.
For A, distances to B,C,D are 1,2,3. Fix sigma=1 for a checkable illustration. Unnormalized weights are exp(−1/2), exp(−2), exp(−9/2): approximately .606531,.135335,.011109. Divide by their sum .752975 to obtain .805512,.179734,.014753. Every bar uses 400 SVG units per probability unit. Even D receives a positive weight; this is not a hard cutoff.
Effective Neighbors, Not A Count
The stacked rows each sum to one. B is mint, C is white, D is gray, with direct identity labels. Widening sigma from 1 to 2 produces .486578,.334420,.179002. The distribution becomes less concentrated.
Perplexity is exp of entropy in natural-log units: . Those rows give 1.724422 and 2.786447. Actual t-SNE adjusts each bandwidth toward a requested perplexity; our fixed bandwidths expose that relationship without claiming a complete fit. There is no universal setting that reveals the true group count.
Merge Directed Local Views
UMAP's construction builds local memberships and combines opposing edge weights by fuzzy union. It then seeks a low-dimensional fuzzy graph using a cross-entropy objective. This does not guarantee the global distances of the original data.
Here we switch to a separate pair-level example: directed memberships a=.5 and b=.25 combine as a+b−ab=.625. These are UMAP memberships, not the Gaussian probabilities above. The rulers share 400 SVG units per membership unit. Adding without subtracting overlap would incorrectly give .75.
See One Attractive Contribution
Return to all four original samples and sigma=1. Symmetrize conditional rows with , n=4. For B,C, both conditional values are .449816, giving P_BC=.112454.
Construct a candidate map with horizontal coordinates 0,1,3,4 and vertical coordinates zero. Its Student-t weights are , normalized over all ordered distinct pairs. The denominator is 2.917647; BC has weight .2, giving Q_BC=.068548. The same ruler beneath compares those pair probabilities.
For this pair, P greater than Q contributes attraction in the gradient . Arrows indicate direction, not a displacement scale. Other pairs also contribute. A full gradient step of size 1, with no momentum or exaggeration, gives approximately (−.043527,1.100045,2.899955,4.043527). This is one computed step, not a converged map or benchmark.
False Proximity Has A Cost
For a separate UMAP edge absent in the input graph, membership p=0 makes its objective term −log(1−q). Map membership q=.1 costs .105361 nats; q=.9 costs 2.302585 nats. The bar scale is 100 SVG units per nat. Treating an absent edge as strongly present is expensive. The dashed line and cross denote that false edge; endpoint spacing is schematic.
The non-edge term penalizes false proximity. It does not punish false separation, as the previous explanation incorrectly claimed. t-SNE also repels mismatched close pairs through its normalized Q; small P does not make a pair irrelevant to the entire objective.
Check Gaps Against The Input
All adjacent input distances are 1. The constructed candidate map above gives adjacent gaps 1,2,1. Both rows use 100 SVG units per coordinate unit. Its enlarged middle gap does not establish that B and C were farther apart in the input. This is an auditable candidate configuration, not an invented t-SNE or UMAP run. Check apparent islands against the input representation and alternative settings.
Axes Have No Fixed Meaning
Rotate the same candidate map by 90 degrees; the two plots share 60 SVG units per map unit. BC remains 2 units long and every pair distance stays unchanged. Distance-based map affinities therefore remain unchanged too. A horizontal coordinate is not inherently a semantic feature, and a rotated map is not a different clustering.
Place A New Observation
The circles are reference samples and the triangle is a fresh observation. This schematic shows input-neighbor connections followed by a candidate placement against fixed reference coordinates. It is not a computed transform position.
UMAP supports transforming new data. Fit the reference on training data before transforming held-out observations. Distribution shift can make placements misleading. Do not infer a hard dataset-size cutoff between methods or a universal speed ordering from this drawing. UMAP's neighbor and packing controls change what structure it emphasizes; evaluate the settings against the task.
Where It Breaks
Switch to a regular tetrahedron: four 3D points with every pair distance 1. One coordinate construction is (0,0,0), (1,0,0), (1/2,√3/2,0), (1/2,√3/6,√(2/3)); squaring coordinate differences verifies all six distances. The left drawing is an oblique schematic, so its screen edge lengths are not measurements.
The square candidate on the right has side 1 and diagonals √2, visibly breaking equality. No alternative planar arrangement can solve this exactly: after fixing two points a unit apart, a third unit-distant point must be one of the two equilateral-triangle tips. The opposite tip lies √3 away from the first tip, so it cannot be the fourth point. A readable 2D map necessarily sacrifices some relationships. Neither algorithm can turn every high-dimensional distance into an exact planar distance.
The Quick Version
- Coordinate selection can hide samples; linear projection need not fail.
- Gaussian affinities weight nearby samples more strongly.
- Perplexity measures effective neighborhood size through entropy.
- UMAP combines local memberships with fuzzy union.
- Pair-affinity mismatch controls attraction and repulsion.
- False map proximity incurs a non-edge cost.
- Apparent map gaps need checking against input relationships.
- Rigid rotations preserve distance-based map affinities.
- UMAP can transform fresh samples against a fitted reference.
- Two dimensions cannot preserve every high-dimensional metric configuration.