# Why scaling is important for the linear SVM classification?

When performing the linear SVM classification, it is often helpful to normalize the training data, for example by subtracting the mean and dividing by the standard deviation, and afterwards scale the test data with the mean and standard deviation of training data. Why this process changes dramatically the classification performance?

• This question has already been answered stackoverflow.com/questions/15436367/svm-scaling-input-values Jul 22, 2013 at 14:49
• Thank you,juampa! However, i am still not quite clear why the test set needs to be scaled with the mean and std of the training set instead of its own? In some case, the later seems perform euqlly well or even better when the two classes of samples are well balanced in the test set. Jul 23, 2013 at 7:27
• because then you are not being consistent. You are testing on different data. Imagine you draw the samples from a Gaussian N(mu,sigma). You trained with N(0,1) (after centering and scaling) but tested with N(mu,sigma) Jul 23, 2013 at 8:15
• Mar 1, 2014 at 0:00
• @Qinghua because that is cheating. In a real-life scenario you would not even have the test data when you train the model. The best you can do is scale with the mean, variance of training set. Aug 26, 2021 at 10:18

• Calling X1 and X2 to be input vectors is not strictly wrong but so uncommon that it is pretty close to being wrong: X1 and X2 are called "variables" or "features". Usually they are real numbers in practice and as such they are strictly speaking also vectors in the mathematical sense (if they are considered to be the underlying set of a vectors space). But in the context of a supervised learning in Euclidean space this is not what people mean. Usually $(X1, X2)$ is called to be the "input vector", instead of X1 and X2. Aug 17, 2020 at 11:09