Skip to content
IT glossary
Data and MLUpdated December 3, 2026

Dimensionality reduction

Понижение размерности

Dimensionality reduction represents each data point with fewer features or coordinates while trying to keep what matters for the task. For example, it can turn hundreds of measurements into two coordinates for a plot.

Also known as: PCA

What gets smaller?

Imagine a spreadsheet with one row per apartment and a column for every measurement. Floor area, room count, and number of bedrooms all say something about size. You might summarize much of their shared variation with a single score. You still have one row per apartment; you just need fewer numbers to describe it.

One approach, feature selection, keeps a subset of the original columns. Another builds new coordinates from the existing features. Principal component analysis (PCA) is a common example of the second approach. It is one dimensionality reduction method, not another name for the whole category.

How PCA chooses the new coordinates

Picture a scatter plot with standardized floor area on one axis and standardized room count on the other. If larger apartments tend to have more rooms, the points form a cloud stretched along a diagonal. PCA finds that direction and projects each apartment onto it. A single coordinate now describes position along the diagonal, but it loses the distinction between apartments that differ only across it.

More generally, PCA subtracts each feature's mean and finds the direction along which the projected data has the most variance. It finds each subsequent direction at right angles to the earlier ones, maximizing the remaining projected variance. Keeping the first k components gives each row k coordinates, each a weighted sum of the centered features. Scaling is a separate choice: if changing square meters to square feet would give floor area more influence than you intend, consider standardizing the inputs before PCA.

Example: compress training and test data

from sklearn.decomposition import PCA
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

reducer = make_pipeline(StandardScaler(), PCA(n_components=0.95))
Z_train = reducer.fit_transform(X_train)
Z_test = reducer.transform(X_test)

The 0.95 setting asks PCA to keep enough components to account for at least 95% of the variance in the standardized training data. The test data uses the same scaling and projection learned from training. Fitting on the combined data would leak information from the test set; fitting a separate PCA on the test set could put its rows in a different coordinate system.

Where it helps, and what interviewers ask

Two or three coordinates are useful for plots. A larger compressed representation may reduce storage or speed up a downstream model. But explained variance is not a measure of predictive value: a small variation in an otherwise stable sensor could be the only warning of a fault, and PCA could discard it.

If asked how many components to keep, start with the goal. For a plot, the display sets the number of dimensions. For compression, compare the size of the representation with the error when reconstructing the inputs. For prediction, compare validation performance against a baseline without PCA. In cross-validation, put PCA and any scaling inside the pipeline so both are fitted only on the training portion of each fold.