I want to rescale the features of my data to be between [0,1] and [-1,1]? Is their a clear cut way that works every time for these ranges? I think the below equation works for [0,1] but when it is describe people say generally it works, so I am not certain it works every single time.
1 Answer
What you said is right, the above equation is for normalizing the data with-in the range of [0,1]
Now, we can generalize using the below equation
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 $$