Min-Max Normalization (with example)

Min-Max normalization performs the linear transformation on original data. Let (X1, X2) be a min and max boundary of an attribute and (Y1, Y2) be the new scale at which we are normalizing, then for Vi  value of the attribute, the normalized value Ui is given as,

Min-Max Normalization

Min-Max Normalization

 Special thing about min-max normalization is that preserves the relationship between the original data values. If in future the input values come to be beyond the limit of normalization, then it will encounter an error known as “out-of-bound error.”

 

Let’s Understand it with an example: Suppose the minimum and maximum values for the price of the house be $125,000 and $925,000 respectively. We need to normalize that price range in between (0,1). We can use min-max normalization to transform any value between them (say, 300,000). In this case, we use the above formula to find Ui with,

Vi=300,000

X1= 125,000

X2= 925,000

Y1= 0

Y2= 1

Min-Max Normalizationmin-max

In python:     

Here is an example to scale a toy data matrix to the [0, 1] range:
from sklearn import preprocessing
import numpy as np X_train = np.array([[ 1., -1.,  2.],                      [ 2.,  0.,  0.],                      [ 0.,  1., -1.]]) min_max_scaler = preprocessing.MinMaxScaler() X_train_minmax = min_max_scaler.fit_transform(X_train) print(X_train_minmax)
 
 output:
 
[[0.5        0.         1.        ]
 [1.         0.5        0.33333333]
 [0.         1.         0.        ]]
 
To read more about Normalization visit here.
 
 

Leave a Reply

Insert math as
Block
Inline
Additional settings
Formula color
Text color
#333333
Type math using LaTeX
Preview
\({}\)
Nothing to preview
Insert
%d bloggers like this: