Standardize Training and Validation Data

I am supposed to standardize a training and a validation set "so that the training set has zero mean and unit $l_2$-norm". In order to do so I use the data.normalization function from R's ClusterSim package,

    normalizedtrainingset <- data.Normalization(trainingdata,type="n12",normalization="column")


which does do the trick for the training set. Now I am a bit confused about how to proceed with the validation set. I surely cannot use the same function because it would use the validation set's mean and sd and not the mean/sd from the training data. Thus, I proceeded like this:

    validation.standardized <- (validation-mean(training))/sd(training)


This takes into account the mean and sd of the training set. However, the values in the validation set are still quite a bit larger than those of the training data because it has not been normalized. My question now is: do I divide the validationset by its own $l_2$-norm, do I divide it by the $l_2$-norm of the training set or do I not divide it at all and the values in the validation set have to remain larger than those in the training data (the latter seems unlikely).

• With regard to the standardization this makes sense. But what about the normalization? All variables and the response of the training set were divided by their $l_2$-norm so that they have unit $l_2$-norm. What do I do about the validation set? Do I divide all variables by the corresponding $l_2$-norm of the training set or do I use the $l_2$-norm of the validation set? Nov 29, 2016 at 11:58
• By 'variance', I meant the $l_2$-norm. You should do exactly the same: use the training set $l_2$-norm to divide the validation set. They will not exactly be of unit norm, but it's the best you can do without 'cheating' by using data from the validation set. Nov 29, 2016 at 12:00