DATA NORMALIZATION - METHODS / APPROACHES IN PYTHON
There are three types of data normalization methods/ approaches. They are
- Simple Feature Scaling method
- Min-Max method
- Z-Score method
1. Simple Feature Scaling method in Python
Formula:
(X old)
X new = -----------
(X max)
Example
df["length"]
df["length"] = ----------------------------
df["length"].max()
OLD Values NEW Values
Length Width Height Length Width Height
--------------------------------------- ---------------------------------------
168.8 64.1 48.8 0.81 64.1 48.8
168.8 64.1 48.8 0.81 64.1 48.8
18.8 65.5 52.4 0.87 65.5 52.4
2. Min-Max method in Python
Formula:
(X old) - (X min)
X new = --------------------------
(X max) - (X min)
Example
df["length"] -df["length"].min()
df["length"] = ------------------------------------------------
df["length"].max() - df["length"].min()
OLD Values NEW Values
Length Width Height Length Width Height
--------------------------------------- -- ---------------------------------------
168.8 64.1 48.8 -- 0.41 64.1 48.8
168.8 64.1 48.8 -- 0.41 64.1 48.8
18.8 65.5 52.4 -- 0.58 65.5 52.4
3. Z - Score method in Python
Formula:
(X old) - meu
X new = -------------------------
sigma
Note:
Meu - Average of the feature
sigma - Standard deviation
Example
df["length"] - df["length"].mean()
df["length"] = -----------------------------------------------
df["length"].std()
OLD Values NEW Values
Length Width Height Length Width Height
--------------------------------------- -- ---------------------------------------
168.8 64.1 48.8 -- 0.41 64.1 48.8
168.8 64.1 48.8 -- 0.41 64.1 48.8
18.8 65.5 52.4 -- 0.58 65.5 52.4
Comments
Post a Comment