# 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 |

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 U_{i} with,

V_{i}=300,000

X_{1}= 125,000

X_{2}= 925,000

Y_{1}= 0

**In python: **

`[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:**