Normalization: Normalization Techniques at A Glance
Normalization: Normalization Techniques at A Glance
scaling to a range
clipping
log scaling
z-score
The following charts show the effect of each normalization technique on the
distribution of the raw
feature (price) on the left.
The charts are based on the data set from 1985 Ward's Automotive
Yearbook that
is part of the UCI Machine Learning Repository under Automobile Data
Set
(https://archive.ics.uci.edu/ml/datasets/automobile).
Scaling to a range
You know the approximate upper and lower bounds on your data with
few or no outliers.
A good example is age. Most age values falls between 0 and 90, and every part of
the range has a
substantial number of people.
In contrast, you would not use scaling on income, because only a few people
have very high
incomes. The upper bound of the linear scale for income would be
very high, and most people would
be squeezed into a small part of the scale.
Feature Clipping
If your data set contains extreme outliers, you might try feature
clipping, which caps all feature
values above (or below) a certain
value to fixed value. For example, you could clip all temperature
values
above 40 to be exactly 40.
Another simple clipping strategy is to clip by z-score to +-Nσ (for example, limit to
+-3σ). Note that σ
is the standard deviation.
Log Scaling
Log scaling is helpful when a handful of your values have many points, while
most other values have
few points. This data distribution is known as the power
law distribution. Movie ratings are a good
example. In the chart below, most
movies have very few ratings (the data in the tail), while a few
have lots of
ratings (the data in the head). Log scaling changes the distribution, helping to
improve
linear model performance.
Z-Score
\[ x' = (x - μ) / σ \]
keyboard_arrow_left
Figure 4. Comparing a raw distribution to its z-score distribution.
Notice that z-score squeezes raw values that have a range of ~40000
down into a range from
roughly -1 to +4.
Suppose you're not sure whether the outliers truly are extreme.
In this case, start with z-score unless
you have feature values that
you don't want the model to learn; for example, the values are
the result
of measurement error or a quirk.
Summary
Normalization
Formula When to Use
Technique
Linear Scaling $$ x' = (x - x_{min}) / (x_{max} - When the feature is more-or-less uniformly distributed
x_{min}) $$ across a fixed range.
Clipping if x > max, then x' = max. if x < min, When the feature contains some extreme outliers.
then x' = min
Log Scaling x' = log(x) When the feature conforms to the power law.
Z-score x' = (x - μ) / σ When the feature distribution does not contain extreme
outliers.
keyboard_arrow_left
erms:
aling (/machine-learning/glossary#scaling) normalization (/machine-learning/glossary#normalization)
Previous
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
(https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the Apache 2.0 License
(https://www.apache.org/licenses/LICENSE-2.0). For details, see the Google Developers Site Policies
(https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates.
keyboard_arrow_left