Mathematics · advanced

PCA & Projection

Principal components as variance-maximizing orthogonal directions; projection as subspace approximation.

mathematicslinear-algebra

Mental model

PCA finds an orthogonal basis ordered by variance. Top-k projection is the best k-dimensional summary in squared-error sense. Center first.

How to study PCA & Projection

Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use StatQuest — PCA, A Tutorial on Principal Component Analysis (Shlens) to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.

Next, compare PCA & Projection with Embeddings (Transformer), Linear Regression. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete PCA variance explained and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.

Proof of understanding

  • Explain the mechanism from first principles and identify the state it reads or changes.
  • Give one situation where the concept is the right choice and one where it is not.
  • Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
  • Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.

Where it matters

Dimensionality reduction, visualization, noise filtering.

Common mistakes

  • PCA on uncentered data
  • Components without domain meaning
  • PCA for prediction without care

Learn from primary sources

Practice and explain it back

PCA variance explained

2D data with cov matrix [[4,3],[3,9]]. Eigenvalues are 10 and 3. What fraction of variance do the top 1 and top 2 components explain? Why center before PCA?

Expected evidence: PC1: 10/13≈77%; both: 100%. Centering removes the mean offset so variance is spread, not dominated by the origin.

Open the interactive drill →

Review prompts

  • Why is PCA a projection?

Build evidence

PCA from scratch

Center data, compute covariance matrix, eigen-decompose, project to 2D. Visualize.

  • Top-2 eigenvectors explain ≥70% variance on a test dataset
  • 2D scatter of projected points
  • One sentence: what the first principal component 'means' for your data

Visualize linear projections

Draw vector projection onto a line/subspace: show orthogonal residual. Connect to OLS geometry.

  • Diagram or plot: vector, subspace, projection, residual orthogonal
  • Numeric check: residual · subspace direction = 0

Prerequisites

Related concepts

Learning paths