← All Posts
Deep Learning · Data Preparation and Preprocessing · Feature Scaling

Normalization vs Standardization

“Normalize the data” is an incomplete instruction. It might mean map each feature into a range, express each feature in standard deviations, or give every example unit length. These operations can produce very different inputs to a model.

In this series, standardization means the usual column-wise z-score transform. Min-max normalization means rescaling columns using their training minima and maxima. Scikit-learn’s Normalizer means row-wise unit-norm normalization. When reading another source, check its actual operation rather than relying on the word alone.

One feature is enough to see the difference

Take three training examples with one numerical feature: 2, 4, and 8. Their mean is about 4.667 and their population standard deviation is about 2.494. The training minimum is 2 and the maximum is 8.

A z-score subtracts 4.667 and divides by 2.494. Min-max scaling subtracts 2 and divides by the range, 6. For L2 row normalization, each row has only one coordinate: its length is that number’s absolute value. Every positive row therefore becomes 1.

Same inputs, three meanings of “normalize”
ExampleInputOutput
Training A2−1.069
Training B4−0.267
Training C81.336
Future D102.138
Z-score: the training column has mean 0 and variance 1. Future D uses the same fitted mean and standard deviation.
The first three rows supply the fitted column statistics. Future D is transformed afterward. Switch to L2 to see all four positive values collapse to 1: their magnitudes are no longer available to the model.

Which information should the model retain?

The two column transforms retain all distinctions among 2, 4, and 8. Their order is unchanged, and the gap from 4 to 8 remains twice the gap from 2 to 4. With the saved parameters, either transform can recover the original values. This assumes a nonconstant reference column and no clipping.

Row normalization deliberately removes length. In our one-feature example, that removes every difference between positive examples. With multiple features, it retains direction: [3, 4] and [6, 8] both become [0.6, 0.8], as the unit-circle figure shows. Use it when direction is the representation you want, and decide whether to retain magnitude separately.

Array shape is therefore part of the meaning. [[2], [4], [8]] is three examples with one feature. [[2, 4, 8]] is one example with three features. A row normalizer performs a different calculation on these two inputs.

Choose the property you need

Intended propertyMethod and limitation
Comparable per-feature spreadStandardization uses the training mean and standard deviation. Extreme values affect both; the original distribution’s shape remains.
Training extrema mapped to chosen endpointsMin-max scaling. Future values can fall outside the interval; clipping is a separate, information-losing choice.
A scale less driven by a few extreme valuesMedian/IQR scaling. This changes the reference statistics but does not remove outliers.
Comparable column magnitudes while keeping sparse zerosMax-abs, or standard deviation scaling without centering. These are fitted column operations.
Each nonzero example has unit lengthRow normalization. Choose the norm and a policy for zero rows; magnitude is discarded.

These are descriptions of behavior, not a ranking of prediction quality. The appropriate choice depends on what distance, regularization, or optimization means for the model. The when-to-scale chapter develops those connections. Compare candidate preprocessing choices using the same validation design.

Write an instruction someone can reproduce

Replace “normalize the features” with a specific instruction, such as: fit a mean and population standard deviation for each numerical column on the training rows, then reuse them to center and scale future rows.

01Training rowsChoose the numeric columns and learn one mean and standard deviation for each.
02Saved parametersStore those numbers with the model and preserve the column order.
03Future rowsApply the same parameters. Do not fit new statistics on this batch.
A fitted column transform has a reference and a reuse step. For row L2 normalization, the divisor instead comes from each incoming row’s own length. Any preceding learned feature transform still needs a training reference.

Also state how missing values, constant columns, clipping, and sparse input are handled when they occur. These choices belong in the preprocessing configuration. During cross-validation, each training fold supplies its own fitted statistics; see the leakage notes for the evaluation boundary.

Two other meanings to keep separate

A normal distribution is a bell-shaped probability distribution. Neither z-scoring nor min-max scaling makes arbitrary data normally distributed. The before-and-after distribution plot shows why: an affine change of units preserves the shape.

Probabilities are another requirement. Mapping a column to [0, 1] does not make its entries a probability distribution or make a score calibrated. For nonzero, nonnegative rows, L1 normalization makes the row sum to 1; that arithmetic property alone does not establish that its entries estimate event probabilities.

Read the API name and the input shape together

The following code reproduces the figure. The two scalers learn from the three training rows. Normalizer exposes the same fit/transform interface but is stateless: it calculates a norm from each row independently.

Run all three transforms
import numpy as np
from sklearn.preprocessing import StandardScaler, MinMaxScaler, Normalizer

# Shape (3, 1): three examples, one feature.
train = np.array([[2.], [4.], [8.]])
future = np.array([[10.]])
for transform in (StandardScaler(), MinMaxScaler(), Normalizer(norm="l2")):
    transform.fit(train)
    values = transform.transform(np.vstack([train, future]))
    print(type(transform).__name__, values.ravel().round(4).tolist())
StandardScaler [-1.069, -0.2673, 1.3363, 2.1381]
MinMaxScaler [0.0, 0.3333, 1.0, 1.3333]
Normalizer [1.0, 1.0, 1.0, 1.0]

For the arithmetic from scratch, use the focused C++ implementations in standardization, min-max scaling, and column scaling versus row normalization. They keep the same distinction visible in code.

References and further reading