See how different feature-scaling methods transform the
same dataset. The synthetic data intentionally contains
a strongly skewed distribution and a few extreme
observations.
StandardScaler
Centers each feature using its mean and scales it
using its standard deviation.
z = (x - mean) / std
Original data
Before scaling
StandardScaler
After scaling
Original feature statistics
Extreme values strongly affect the mean and standard
deviation, while median and IQR are much more stable.
Statistic
X1
X2
Mean
-
-
Standard deviation
-
-
Median
-
-
IQR
-
-
Minimum
-
-
Maximum
-
-
What should you notice?
Most observations are concentrated in a relatively
small region, while a few observations are extremely
far away.
StandardScaler
uses the mean and standard deviation. Because both
statistics are affected by extreme observations,
ordinary observations can become compressed.
RobustScaler
uses the median and interquartile range (IQR).
These statistics are much less sensitive to extreme
observations, so the main cloud remains easier to see.
MinMaxScaler
uses the minimum and maximum. Extreme observations
can therefore squeeze almost all normal observations
into a small portion of the range.
MaxAbsScaler
divides by the largest absolute value, so an extreme
observation can strongly affect the resulting scale.
Normalizer
is different. It normalizes each individual observation
based on its vector length rather than calculating
statistics across the dataset.