Lensa ML
Lensa ML

Feature Scaling

Step 1 of 6

The Scale Problem

Why different feature ranges cause trouble

2D scatter: equal-scale axes (1 unit = same length on both axes)
Feature 1 (Age)Feature 2(Salary)5210315552103155
Scale factor for Feature 21x
F1 RANGE
18-76
F2 RANGE
35-196
SCALE RATIO
2.8x

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

2D scatter: equal-scale axes (1 unit = same length on both axes)
Feature 1 (Age)Feature 2(Salary)5210315552103155
Scale factor for Feature 21x
F1 RANGE
18-76
F2 RANGE
35-196
SCALE RATIO
2.8x

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

Loss contours and gradient descent path:
w1w2minstart
Scale ratio between features1.0
SCALE RATIO
1.0x
GD STEPS
22
EFFICIENCY
100%

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]

xnorm = (x - min) / (max - min)
Raw data (shared scale) vs. Min-Max normalized [0, 1]:
Raw (shared scale)AgeSalary5151031154651510311546Normalized [0,1]Age (norm)Salary (norm)000.50.511
Select data pointPoint 1
RAW AGE
34.0
NORM AGE
0.276
NORM SALARY
0.000

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

z = (x - μ) / σ
Raw data (shared scale) vs. Standardized (mean=0, std=1):
Raw (shared scale)AgeSalary5151031154651510311546StandardizedAge (z)Salary (z)-1-10011(0,0)
Select data pointPoint 1
RAW AGE
34.0
Z (AGE)
-0.515
Z (SALARY)
-1.251

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

Relative loss (normalized to 1.0 at start):
Training StepRelative Loss01530456000.250.50.7511%ScaledUnscaled
Learning rate0.010
UNSCALED
22
SCALED
>60
SPEEDUP
0.4x

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

Does this model need feature scaling?
LinearRegressionScale!Gradient-basedNeuralNetworkScale!Gradient-basedDecisionTreeNot neededSplit-basedk-NNScale!Distance-based
SCALE-SENSITIVE?
Yes
TYPE
Gradient-based

Uses gradient descent, so features on different scales cause uneven updates. Coefficients become hard to interpret. Always scale features before training this model type.