Feature Scaling
The Scale Problem
Why different feature ranges cause trouble
Both features have similar ranges, so the scatter plot looks well-distributed. Each feature contributes equally to distance calculations and gradient updates.
Step 1 of 6: The Scale Problem
Why different feature ranges cause trouble
Both features have similar ranges, so the scatter plot looks well-distributed. Each feature contributes equally to distance calculations and gradient updates.
Step 2 of 6: Elongated Contours
How unbalanced scales distort gradient descent
With balanced scales, loss contours are nearly circular. Gradient descent takes a direct path to the minimum with high efficiency. Each step moves meaningfully toward the goal.
Step 3 of 6: Min-Max Normalization
Squeezing features into [0, 1]
Min-max normalization squeezes every feature into [0, 1]. The left plot shows the raw scale problem — salary (300-2000) dominates age (18-80). The right plot shows the fix: both axes now span [0, 1], revealing the true relationship between features.
Step 4 of 6: Standardization (Z-score)
Centering at zero with unit variance
Standardization uses mean and standard deviation instead of min and max. The left plot shows the raw scale distortion. The right plot shows the fix: both features are centered at zero with unit variance, revealing the true data structure.
Step 5 of 6: Effect on Training
Scaled features converge faster
Both models are stable at this small learning rate. The unscaled model converges slowly because the small eigenvalue (1) makes progress crawl along one axis, while the large eigenvalue (100) keeps the other axis barely moving. The scaled model converges evenly.
Step 6 of 6: When to Scale
Which models need it and which do not
Uses gradient descent, so features on different scales cause uneven updates. Coefficients become hard to interpret. Always scale features before training this model type.