2.5.11 · D1Unsupervised Learning

Foundations — t-SNE for visualization

1,991 words9 min readBack to topic

Everything else on the parent note is machinery serving that one sentence. Below we unpack every symbol it uses, from absolute zero, in an order where each idea is built only from ones already explained.


1. A "point" and its dimensions — , ,

A point is just a list of numbers. If you measure a flower's petal length, petal width, and stem length, that flower becomes the list . Each number is one feature.

  • = the number of features = how many numbers are in each list. Petal example: .
  • = the -th point (the bold letter means "this is a whole list, not one number"). The little is just a name tag: is the first flower, the second.
  • = how many points you have in total. 300 flowers means .
  • = "the space of all lists of real numbers." is the flat page (2 numbers = left/right, up/down). is a space you cannot picture — but the maths treats it exactly the same.

2. Distance between two points —

To say "these two flowers are similar," we need to measure how far apart their lists are.

  • means subtract the lists slot by slot. .
  • (double bars) = the length of that difference arrow — the straight-line distance. From : length .
  • = that length squared (). We keep it squared because it avoids the square root (faster, and the maths later stays smooth).

3. The Gaussian bump —

We now turn "distance" into "similarity." We want: distance similarity high; big distance similarity near ; and a smooth fall-off in between.

The function that does exactly this is the Gaussian bell curve:

Reading it piece by piece:

  • means raised to that power, where . When the something is , (max similarity). When it is very negative, crashes toward .
  • The minus sign flips it: more distance more negative exponent smaller similarity. Exactly what we wanted.
  • (sigma) = the width of the bell for point . A wide bell means "I still count faraway points as neighbours"; a narrow bell means "only my closest friends count." The little says each point gets its own width.

See 1.3.5 KL Divergence later for how these similarities become the thing we minimise.


4. Turning similarities into a probability — , , and normalisation

A single similarity number is not yet a probability. A probability must be between and , and all of a point's options must add up to . We achieve that by dividing each similarity by the total of all similarities.

  • (capital sigma) = "add up over every point , except itself." It is a loop: try , then , …, skip , sum the results.
  • = "the probability point picks as its neighbour." Read the bar as "given": given that we are standing at , how likely is ?

Note is not symmetric: because and can have different bell widths , the attention gives need not equal the attention gives .


5. Making it fair both ways —

t-SNE prefers a joint probability that treats the pair as one thing, with no direction:

  • Adding the two directions and averaging removes the bias, so .
  • Dividing by makes all the across every pair add up to — now (the whole collection of ) is one honest probability distribution over pairs.

6. Perplexity and entropy — the knob for

How do we choose each ? We don't set it directly; we set a target perplexity — roughly "how many neighbours should each point pay attention to."

  • Entropy measures how spread out point 's attention is. All attention on one neighbour . Attention split evenly over many large .
  • Perplexity converts that entropy into an intuitive count: "effective number of neighbours." Perplexity ≈ each point behaves as if it has about meaningful neighbours.
  • A binary search then tunes up or down until the point's perplexity hits your chosen target.

7. The low-D twins — and the t-distribution

Now the destination room, . Each high-D point gets a partner dot on the page. We define a matching similarity there, but with a different curve:

  • means "one over ..." — a reciprocal.
  • This is the Student t-distribution (with 1 degree of freedom). Compared to the Gaussian it has a heavy tail: it falls off gently, so even moderately far dots keep a non-tiny .

8. KL divergence — the scorecard

We have two probability collections: (upstairs, fixed) and (downstairs, movable). We need one number saying "how badly does disagree with ?" That number is the Kullback–Leibler divergence:

  • is when the two agree, positive when is too small, and each term is weighted by — so mismatches on true neighbours (large ) hurt the most.
  • always, and only when exactly matches . So "minimise " literally means "make the picture faithful."

Full treatment lives in 1.3.5 KL Divergence.


9. Derivative / gradient —

To reduce we need to know: if I nudge dot a little, does go up or down? That question is exactly what a derivative answers — it is the slope of as a function of .

  • (curly d) means "rate of change with respect to just this one thing, holding others fixed."
  • is a 2D arrow (one slope per coordinate) pointing in the direction that increases fastest. So we step the opposite way — this is gradient descent.

Read it as springs: is the spring's sign/strength (want them closer or further), is the direction, and the last factor is the t-weight. See 2.4.3 K-Means Clustering for a gentler first taste of iterative point-moving, and 3.2.1 Autoencoders / 2.5.10 UMAP for alternative ways to reach low-D. The manifold idea underneath it all is in 2.5.9 Manifold Learning.


Prerequisite map

Point as a list of numbers

Distance between points

Gaussian similarity bump

Conditional probability p j given i

Symmetric joint p ij

Entropy and Perplexity

KL divergence cost C

Low-D dots y and t-distribution q ij

Derivative gradient of C

t-SNE embedding


Equipment checklist

What does the bold mean and how big is it?
A whole list of numbers — one point living in ; is just its name tag.
How do you compute ?
Subtract slot by slot, square each difference, add them up (skip the square root).
Why use instead of ?
It is bounded, smooth, and gives one clean width knob ; blows up at distance .
What does the bar in mean?
"Given" — standing at , the probability of picking ; it is a directional, one-point view.
Why divide by the sum ?
To normalise, so a point's neighbour probabilities add to exactly .
What is perplexity in one phrase?
The effective number of neighbours a point considers, where is its attention-entropy.
Why does low-D use a t-distribution, not a Gaussian?
Its heavy tail solves crowding — moderately far dots keep room to spread instead of piling up.
What does mean?
The low-D similarities perfectly match the high-D ones — a faithful map.
What does tell you?
The direction that increases the cost fastest; move the opposite way to descend.