Solved – How to normalize data between -1 and 1

datasetnormalization

I have seen the min-max normalization formula but that normalizes values between 0 and 1. How would I normalize my data between -1 and 1? I have both negative and positive values in my data matrix.

Best Answer

With: $$ x' = \frac{x - \min{x}}{\max{x} - \min{x}} $$ you normalize your feature $x$ in $[0,1]$.

To normalize in $[-1,1]$ you can use:

$$ x'' = 2\frac{x - \min{x}}{\max{x} - \min{x}} - 1 $$

In general, you can always get a new variable $x'''$ in $[a,b]$:

$$ x''' = (b-a)\frac{x - \min{x}}{\max{x} - \min{x}} + a $$

Related Question