Lesson 3.12core3 h⚡ live demo

Dimensionality reduction: PCA, t-SNE and UMAP

Finding the few directions that matter

High-dimensional data is mostly empty space; dimensionality reduction finds the low-dimensional structure hiding inside it. PCA is the single most-used algorithm in data science and the cleanest application of the eigenvectors and SVD you learned in 1.3 Eigen-things, SVD and low rank. t-SNE and UMAP are how you will actually look at embeddings from word vectors (6.3 Word embeddings) to LLM activations (8.11 Interpretability: what is happening inside), and knowing what their pictures do and do not mean saves you from a whole genre of wrong conclusions.

You'll be able to

  • Derive PCA as variance maximization and as reconstruction minimization, and compute it via eigen-decomposition or SVD
  • Choose the number of components with explained variance and apply PCA correctly (centering, scaling, whitening)
  • Explain how t-SNE and UMAP work and interpret their plots without over-reading them
  • Connect PCA to autoencoders, low-rank structure and embedding geometry

Key ideas

  1. PCA finds orthogonal directions of maximal variance: they are the eigenvectors of the covariance S = XᵀX/n, and each eigenvalue is the variance captured.
  2. Equivalently PCA minimizes reconstruction error; by Eckart–Young it is the truncated SVD X ≈ U_kΣ_kV_kᵀ, with λⱼ = σⱼ²/n.
  3. Center always, standardize when units differ, choose k by cumulative explained variance (≈90–95%), fit inside the training pipeline.
Show 4 more key ideas
  1. Variance ≠ relevance: PCA is unsupervised and can discard a low-variance direction that predicts the label.
  2. t-SNE matches neighbour probabilities with a heavy-tailed Student-t kernel by minimizing KL(P‖Q); perplexity sets the neighbourhood size.
  3. On t-SNE/UMAP plots, cluster sizes and inter-cluster distances are not meaningful; run several settings and never measure on the plot.
  4. UMAP is faster, keeps more global structure and can transform new points; a linear autoencoder recovers the PCA subspace.

Suggested path through this lesson