Scaling data into $[-1,1]$

68 Views Asked by At

I have a data in the matrix for:

\begin{bmatrix} 1 & 2 & 3 & 9 & 6\\ 8 & 2 & 7 & 4 & 6 \\ 1 & 2 & 8 & 7 & 4 \end{bmatrix}

Each row corresponds to a vector $x_i$. I want to re-scale this data into $[-1,1]$ with zero mean. I am new in this domain.

I am trying to train this data in SVM. I try subtracting each row $x_i$ by its mean, and then divide by its variance

$$x_i=\frac{x_i - \operatorname{mean}(x_i)}{\operatorname{std}(x_i)},$$

but I don't get my aim.

2

There are 2 best solutions below

0
On

$y_i=\frac{x_i - \operatorname{mean}(x_i)}{\operatorname{std}(x_i)}$ is a sequence with mean $0$ and standard deviation of $1$. If you want all of $y_i$ to be contained in $[-1, 1]$, divide by $\max{|x_i-\operatorname{mean}(x_i)|}$ instead.

0
On

You can also use $y_i = \frac{x_i - \text{mean}(x_i)}{\max(x_i) - \min(x_i)}$ to get all $y_i$ in the $[-1,1]$ range with $0$ mean.