05 · Learning path
PCA (Principal Component Analysis)
Reduces the dimensionality of the data while keeping most of its variance.
PCA (Principal Component Analysis) transforms a set of correlated variables into a smaller number of uncorrelated variables, called principal components, that retain most of the variance.
Visualize the dimensionality reduction
In this 3D simulator, a cloud of points is projected onto a 2-dimensional plane (PC1 and PC2) while losing as little information as possible.
PCA visualizer
From three dimensions to two
Full view
99.0% of variance
PC1 and PC2 capture almost all of the variation; PC3 is the residual direction.
Explained variance
Covariance eigenvalues: 4.05 · 0.78 · 0.05
What to look for
- The components are the eigenvectors of the covariance matrix, ordered by eigenvalue.
- Projecting means keeping the coordinates along PC1 and PC2 and discarding PC3.
- If the last eigenvalue is small, little information is lost.
What it is for
- Reducing noise: by keeping the components that explain most of the variance, we discard directions dominated by noise (like the red axis PC3).
- Visualizing: it lets you project high-dimensional data down to 2 or 3 dimensions for plotting.
- Gaining efficiency: models train faster with fewer variables.
Geometric intuition
The idea is to “rotate” the data space until we look at it from the most informative angle: the one that maximizes the spread of the points.
The algorithm step by step
1. Centering and standardization
So that variables with large scales (like “income”) do not dominate those with small scales (like “age”), we rescale each column:
This leaves each variable with zero mean and unit variance. If you only center (without dividing by
2. Covariance matrix
We compute the matrix
3. Eigenvalues and eigenvectors
The principal axes are the eigenvectors of
- Eigenvalues
: indicate importance; each one is the variance captured along its direction. - Eigenvectors
: indicate direction; they define the new axes (the lines in the simulator).
The fraction of variance explained by component
4. Projection
We choose the