2.5.12 · D1Unsupervised Learning

Foundations — UMAP for dimensionality reduction

3,813 words17 min readBack to topic

Before you can read a single formula in the parent note, you need to be fluent in a small pile of symbols. This page unpacks every one of them, in an order where each rests on the previous. We build from absolutely nothing — no prior linear algebra, no calculus jargon assumed.


0. What "a point in many dimensions" even means

The very first symbol the parent throws at you is . Let us earn every piece of it.

Figure s01 — one object, more slots. Look left to right: the same thing (a point, drawn as an orange dot) is a dot on a line when it has 1 number, a dot on a sheet when it has 2, a dot in a box when it has 3. The teal labels count the numbers. The lesson to carry away: adding dimensions just means adding measurement slots — the pattern keeps going even after we run out of ways to draw it (like the 784-D digit).


1. Distance — the ruler between two points

Every UMAP formula starts with , the distance between point and point . We must define what "distance" means before using it.

Figure s02 — distance is just Pythagoras. The two black dots are points and . The dashed teal segment is the horizontal gap (here 3), the dashed orange segment is the vertical gap (here 2), and the solid plum line is the actual distance between them. Notice the plum line is the hypotenuse of the right triangle formed by the two gaps — so its length is . That is exactly what "Euclidean distance" computes; in higher dimensions we just have more gaps to square and add.


2. Neighbours — the set and the hyperparameter

Before the friendship formula, we must say which points count as neighbours of .


3. Turning distance into a "friendship weight"

The parent's core high-D formula is Three new pieces to earn: , , and the parameters .

Figure s03 — the friendship weight fades from 1 down to 0. The horizontal axis is distance ; the vertical axis is the weight . Follow either curve from left to right: it starts flat at weight up to the dashed orange line at (the nearest-neighbour distance), then slides smoothly toward — never crossing below zero. Compare the two curves: the plum one (small ) drops steeply so only very close points keep any weight, while the teal one (large ) fades gently so farther points still count. That contrast is what controls.


4. Summation and logarithm — reading the calibration target

The parent sets . Two more notations — and recall from Section 2 that is the -nearest-neighbour set and is n_neighbors.


5. Making the graph undirected — the fuzzy union

So far is directed: it is "how strongly reaches toward ," and need not equal . We now define a single undirected edge weight, written with the superscript "sym" (for symmetric):


6. The low-D kernel — drawing bonds in 2-D

The parent's low-D weight:


7. Comparing two structures — cross-entropy

The final objective compares the high-D bonds against the low-D bonds using cross-entropy, written (a script "L" for Loss — the single number we push downhill).


How the foundations feed UMAP

Point as list of numbers

Distance d_ij

Metric choice

Neighbour set N of i, size k

Exponential fade to weight w_ij

rho_i nearest neighbour

sigma_i local bandwidth

Sum and log2 k calibration

Fuzzy union symmetrize

High-D graph

Low-D positions y_i

Low-D kernel v_ij

min_dist hyperparameter

Cross-entropy loss compare

Gradient descent moves y_i

Final 2-D UMAP plot

Every arrow is a symbol you now own. Related big-picture methods worth knowing: PCA and Random Projection (linear squashing), Isomap and Spectral Clustering (graph/manifold cousins), Autoencoders (neural squashing), and the deeper theory in Topological Data Analysis.


Equipment checklist

Try to answer each before revealing. If any stumps you, re-read its section above.

What is the bold-face convention for matrices vs vectors?
Bold uppercase (e.g. , ) is a whole matrix/table; plain lowercase with a subscript (e.g. , ) is one row — a single point/vector.
What does mean in plain words?
is the data matrix: a table of real numbers with rows (one per data point) and columns (one per measurement).
What is and what is ?
is the output matrix — the finished layout with rows and columns; is the small target dimension (usually 2), so the result can be plotted.
What is the difference between and ?
is the original high-D data point (a row of ); is its finished low-D position (a row of ), the dot on the plot.
What do the subscripts in tell you?
That distance needs two points — point number and point number .
Why can you subtract , and what does compute?
Because both are vectors of the same length, so you subtract slot by slot; the double bars then give the straight-line (Euclidean, ) length of that difference.
What is a "metric" and name two besides Euclidean.
The ruler used to turn two points into a distance ; e.g. Manhattan (, sum of absolute gaps) and cosine (angle between the arrows).
What is , and is itself in it?
The set of the nearest neighbours of point ; no — is excluded (a point is not its own neighbour).
What constraint must (n_neighbors) satisfy and why?
— you cannot have more neighbours than there are other points; needs .
For which is non-zero?
Only for (the nearest neighbours); for all other $