Principal Component Analysis Explained: Squashing Data Without Losing It

Principal component analysis explained in plain terms means understanding how to squash a cloud of data into fewer dimensions without losing what matters. The central question is how to throw away most of the numbers describing something and keep the meaning, and the answer is to stop looking at the data from the axes it arrived on, and start looking at it from the directions where it actually varies.

Principal component analysis, usually called PCA, is a technique that finds the directions of greatest variance in a dataset, rotates the data onto those directions, and keeps only the first few, which capture most of the information. The new directions are called principal components, and they are uncorrelated with each other.

Picture a cloud of points shaped like a long, thin cigar, floating at an angle in three dimensions. That is the whole idea. This article explains what PCA is, how it works, and where it is used.

Key takeaways

  • PCA finds the directions where the data varies the most.
  • Keeping the first few components shrinks the data with little loss.
  • The components are uncorrelated and ordered by importance.
  • It works best when the structure is linear and the features are scaled.
  • It is used for compression, visualisation, and cleaning up noisy data.

What principal component analysis is

That cigar-shaped cloud is the key. The cloud is long in one direction and thin in the other two, so most of its spread is along its length, and describing a point by its position along that length captures almost everything about it. PCA finds that long direction, calls it the first principal component, then finds the next most important direction at right angles to it, and so on, until every direction is accounted for.

The components are found from the covariance of the data, which measures how the features vary together. The first component is the direction that maximises the variance of the projected data, the second is the direction of greatest remaining variance that is perpendicular to the first, and each one after that follows the same rule, which is why the components never repeat information.

PCA was introduced by Karl Pearson in 1901, as a way of fitting lines and planes to data, and Harold Hotelling developed it into a general method in the 1930s. It is one of the oldest tools in statistics, and it is still one of the first things a data scientist tries, because it is fast, it needs no labels, and it often reveals structure that was invisible in the original features. Our guide to data mining explains the field PCA serves, and our guide to linear regression explains the line-fitting idea it generalises.

How principal component analysis works

The process starts with standardising the data, which is a step that matters more than it looks. Each feature is centred on its mean and scaled to unit variance, so that a feature measured in thousands does not dominate the analysis purely because its numbers are bigger, and every feature gets a fair chance to contribute.

Next comes the covariance matrix, which records how every pair of features varies together, and its eigenvectors and eigenvalues are computed. Each eigenvector is a principal component, a direction in the original feature space, and its eigenvalue is the variance the data has along that direction, which is how the components are ranked from most to least important.

Choosing how many components to keep is the main decision. A scree plot, which shows the variance explained by each component in order, usually falls steeply and then flattens, and the components before the flattening are the ones worth keeping. A common rule is to keep enough components to explain ninety or ninety-five percent of the variance, and to drop the rest as noise.

Projecting the data onto the kept components produces the reduced dataset, with each example described by a handful of numbers instead of hundreds. Those numbers are the coordinates of each example along the principal directions, and because the directions are uncorrelated, the reduced features carry no redundant information.

Reconstructing the data from the kept components shows what was lost. Multiplying the reduced coordinates back by the components gives an approximation of the original data, and the difference between the approximation and the original is the reconstruction error, which is small when the kept components explain most of the variance, and which grows as more components are dropped.

A dark office with a glowing green cloud of points flattening into a single bright line across a glass board
A dark office with a glowing green cloud of points flattening into a single bright line across a glass board, shows how principal component analysis works: find the direction the data stretches, and describe it from there.

Comparing principal component analysis with other reduction methods

Principal component analysis is one of several ways to shrink data, and each was built with a different emphasis. Feature selection simply drops the least useful original features, autoencoders learn a non-linear compression with a neural network, and t-SNE is designed for visualisation rather than modelling, and each approach trades simplicity for power in a different way.

The table below sets out the main contrasts between the leading approaches.

Aspect PCA Feature selection Autoencoder
How it shrinks Rotates onto top variance directions Drops whole features Learns a compressed encoding
Linear or not Linear only Not applicable Non-linear
Needs labels No Usually yes No
Interpretability Good, components are directions Excellent, keeps real features Poor, learned encoding
Best for Fast, general reduction Keeping features meaningful Complex, curved structure

The practical result is that PCA is the right first choice for fast, general dimensionality reduction, feature selection suits work where the original features must stay meaningful, and an autoencoder fits data whose structure is curved rather than flat.

Where principal component analysis is used

Face recognition was one of PCA’s most famous applications. Eigenfaces, introduced in the early 1990s, represent each face as a combination of a few principal components of a face dataset, and a new face is recognised by comparing its component weights with those of known faces, which works because faces vary along a small number of meaningful directions.

Data visualisation uses PCA to draw high-dimensional data on a flat page. Plotting the first two principal components shows the structure of a dataset with hundreds of features, and clusters that were invisible in the original space often appear as clear groups in the plot.

Genetics uses PCA to find population structure. A genome has millions of markers, but the first few principal components of a population sample reveal ancestry and migration patterns, and the plot of the first two components is now a standard figure in genetic studies.

Finance uses PCA to summarise the yield curve. The movements of interest rates at different maturities are highly correlated, and the first three principal components, usually described as level, slope, and curvature, capture almost all of the variation, which simplifies risk modelling enormously.

Image compression uses PCA to shrink pictures. An image can be treated as a set of patches, each described by its principal components, and keeping only the top components produces a recognisable image at a fraction of the size, which is the same idea behind the more familiar JPEG, done with a fixed transform instead of a learned one.

Strengths and limits

The greatest strength of PCA is its speed and simplicity. It needs no labels, it runs on a single matrix decomposition, and it gives an answer that is easy to inspect, which is why it is usually the first reduction method tried, and often the only one needed.

It is also a strength that PCA removes redundancy cleanly. The components are uncorrelated, so the reduced features carry no duplicated information, which makes downstream models faster and less prone to the instability that correlated features cause.

The limits are real, though. PCA only finds linear structure, so a dataset that curves through space will be flattened badly, and the components themselves can be hard to interpret, because each one is a mixture of many original features. For curved structure, a non-linear method is needed, and for interpretation, keeping the original features may be better.

Principal component analysis checklist

  • Standardise your features before running PCA, or the scales will dominate.
  • Use a scree plot to decide how many components to keep.
  • Keep enough components to explain ninety percent of the variance.
  • Check what the components mean before trusting them blindly.
  • Use PCA to visualise high-dimensional data in two dimensions.
  • Do not use PCA where the structure is curved; try a non-linear method.
  • Remember the components are mixtures, not original features.
  • Fit PCA on training data only, then apply it to the rest.
  • Measure reconstruction error to know what you threw away.

Frequently asked questions

What is principal component analysis in simple terms?

It is a way of rotating data onto the directions where it varies most, and keeping only the first few of those directions, so the data shrinks with little information lost.

What is a principal component?

It is a direction in the original feature space, found from the covariance of the data, along which the data has the greatest variance, with each later component perpendicular to the ones before it.

How many components should I keep?

Enough to explain most of the variance, often ninety or ninety-five percent, which the scree plot usually makes obvious, as the curve falls steeply and then flattens.

Does PCA need labelled data?

No. It is unsupervised, working only from the variance in the features, which is why it can be run on any dataset before any modelling begins.

Why must features be standardised first?

Because PCA finds directions of greatest variance, and a feature measured in thousands would dominate the result purely through its scale, not its importance.

When should I not use PCA?

When the structure is non-linear, when the original features must stay interpretable, or when the important signal lives in low-variance directions that PCA would discard.

The bottom line

Principal component analysis explained in one line is this: find the directions your data actually stretches, describe it from there, and drop the rest.

It is the oldest dimensionality reduction method still in daily use, and the reason a dataset with hundreds of features can often be understood in two or three.

This article is general information about how principal component analysis works, not advice about choosing dimensionality reduction for a particular project.

Latest articles

Scroll to Top