Principal Component Analysis
Finding the directions along which data varies most: the top eigenvectors of its covariance matrix, used to compress and visualise data.
Needs a step first: 28
Centre the data, form its covariance matrix, and find that matrix's eigenvectors. The one with the largest eigenvalue is the first principal component, the direction of greatest spread; each eigenvalue is the variance along its direction. Keeping only the top few components gives the best low-dimensional approximation of the data in the least-squares sense, which is the singular value decomposition at work. PCA is the first example of learning a representation without labels, the idea that embeddings carry much further.
Where it shows up: Low-dimensional summaries like this lead to embeddings, and the same eigen-analysis appears in quantum mechanics as finding observables' eigenstates.
How to hold it: In your head
See principal components as the directions the data spreads along most, the top eigenvectors of the covariance matrix, each eigenvalue being the variance along its direction; a library finds them for you.
What knowing it looks like
- Compute the covariance matrix of a few 2D points and find its principal components.
- Say what fraction of the variance the first component explains.
- Project points onto the first component and reconstruct them from it.
Test yourself
The points , , , have mean zero. Using the covariance matrix with divisor , find the principal components, the share of variance the first explains, and each point's coordinate along the first component.
Show the worked answer
Needs a step first: 28
Learn it with an AI
Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.
Be my maths tutor. I'm learning "Principal Component Analysis" (Undergraduate II tier): Finding the directions along which data varies most: the top eigenvectors of its covariance matrix, used to compress and visualise data. I already know: Singular Value Decomposition, Joint Distributions and Covariance. Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away. Finish by testing me with this: The points $(2, 2)$, $(-2, -2)$, $(1, -1)$, $(-1, 1)$ have mean zero. Using the covariance matrix with divisor $n = 4$, find the principal components, the share of variance the first explains, and each point's coordinate along the first component. Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.
Needs first
- Singular Value DecompositionEvery matrix, of any shape, is a rotation, then a stretch along perpendicular axes, then another rotation.Undergraduate II · Linear Algebra
- Joint Distributions and CovarianceHow two or more random quantities behave together, and covariance, which measures whether they tend to rise and fall together.Undergraduate I · Probability & Statistics
Leads to
This is the end of a path.
Recommended
- Neural Networks: Zero to HeroAndrej Karpathy · VideosFree lectures that build backpropagation, a language model and a small GPT from scratch in Python, explaining every line.
- Understanding Deep LearningSimon J. D. Prince (MIT Press) · BookA clear, well-illustrated 2023 textbook covering networks, training, transformers, diffusion models and reinforcement learning, free as a PDF with Python notebooks.
- 动手学深度学习阿斯顿·张、李沐等 · Book · 中文The Chinese edition of Dive into Deep Learning: a free textbook in which every model, from linear regression to transformers, runs as code beside the maths.
- 跟李沐学AI李沐 · Videos · 中文Mu Li's own Bilibili channel: the video course for Dive into Deep Learning and paragraph-by-paragraph readings of key papers, including the Transformer paper.