Data Science Foundations · Intermediate

Principal Component Analysis

Reveal PCA in calculation order: raw data → centering/scaling → covariance → eigenvectors → projection.

A staged two-feature PCA studio that progressively reveals the exact transformation, covariance matrix, eigenpairs, explained variance, and point projections. A point inspector connects each visual step to the actual numbers used in the formulas.

Step by step

  1. Start with the raw feature coordinates and locate the sample mean.
  2. Center every point and optionally standardize each feature.
  3. Build the exact 2×2 covariance matrix from transformed points.
  4. Solve Cv = λv and order the two orthogonal principal directions.
  5. Inspect how much variance PC1 and PC2 explain.
  6. Project a selected point and the dataset onto the principal axes.

Core formulas

Covariance matrix

C = (1/(n−1)) XᵀX

After centering, covariance captures the directions in which features vary together.

Eigenvector equation

Cv = λv

Principal directions are covariance eigenvectors.

Explained variance ratio

EVRᵢ = λᵢ / Σⱼ λⱼ

Each eigenvalue tells how much variance its principal direction explains.

When to use Principal Component Analysis

  • Understanding correlated features.
  • Learning dimensionality reduction before using larger datasets.
  • Seeing how standardization changes PCA when feature scales differ.

Primary references

scikit-learn — Principal component analysis

scikit-learn — Importance of feature scaling for PCA