pca() — Principal Component Analysis

Finds the directions along which the data varies the most.

pca(X)

Key idea

Definition

a principal-component direction (unit vector)
the covariance matrix of the data
the variance along w (an eigenvalue)
the data projected onto w

In plain words

Tilt your head until the data looks as stretched-out as possible. That tilt is the first principal component.

Where you'd use it

Frequently asked questions

What does PCA do?
Finds new axes (components) capturing the most variance, for compression or visualisation.
Do I scale first?
Yes — otherwise large-variance features dominate the components.