# How to scale new datas when a training set already exists

Here is what I have :

A scaled training set, with labels.

Segmented images, from which I extract new vectors to classify.

My classifier is a KNN which would have obviously been trained using my training set.

Now, I wonder how I should scale those new vectors I just got. Is this correct to scale them on their own, or should I do something else ? I wonder for example if an outlier would have an effect on the scaling and subsequent classification...

[EDIT] adding an outlier (which I would like to detect using kNN algorithm) to the test datas does impact the scaling, so subsequent classification won't work properly. What should I do then ?

[EDIT 2] This is how I scale my data :

Which in Scilab I translate to :

function dataout = scaledata(datain)

dataout = zeros(size(datain,1),size(datain,2));

for i=1:size(datain,2)
dataout(1:size(datain,1),i) = (datain(1:$,i) - min(datain(1:$,i))) / ...
(max(datain(1:$,i)) - min(datain(1:$,i)));
end

endfunction


Thank you

• How do you scaled your training data? – zeferino Mar 6 '13 at 19:59

To maintain the same normalization of data you need to store the values ​​of min and max to apply on the new vectors. If you need to keep the coordinates of vectors within specific limits ($x \in [-1, 1]$, for example), it is necessary for min and max to be the limits that the coordinates can achieve (considering its domain), and not max and min of training data.
• You have to keep the max and min from training data. For example, if your min = -15 and max = 10 for the training data, you have the use then for the new values. Considering an sample from testing data, (x = 7), the scaled version is $\dfrac{7 - (-15)}{10 -(-15)}$. There is no update for min and max for the new vectors. They remain fixed for the whole testing data. – zeferino Mar 6 '13 at 21:26