I am trying to standardize my data to performing prediction on it.

Some of the features in my data are skewed and hence I am applying Box Cox transformation to reduce skewness.

My data also contains negative values as well as zeros and as Box Cox transformation does not work on negative values, I shift my data set to make all values positive.

Using : F[i] = F[i] + 1 - min(F) , where F is one of my feature

Please not that my train and test data sets are different, and both have different means.

I need to apply the same transformation to train as well as test data sets

How do I apply it to train and test data set ?

1) Should I apply Box Cox to train data set, capture the parameters, like, shifting constant (the constant used to shift train data set), lambda and use the same parameters for test data set ?


2) Should I apply Box Cox to train and test data set independently ? Not considering the train data set parameters while applying Box Cox on test data set ?

  • $\begingroup$ You should use the same constant value to shift your data but it does not necessarily lead to have features with positive values in the test set too because you should not use the range of features to select the constant additive value. as a solution you can use a if-condition to set possible negative values in the test set to zero or use a constant value that theoretically guarantees the features to become positive $\endgroup$
    – Remy
    Commented May 7, 2021 at 16:30

1 Answer 1


The data in the training and test sets should have the same meaning. If you standardize the data based in the mean and standard deviation or using a Box-Cox transformation, you should use in the testing set the means/SDs or lambda calculated in the training set.

  • $\begingroup$ You should look upon choosing transformation parameters via Box-Cox as a form of model choice. So this is the same principle as always use the same model in the test set, as was estimated in the training set. If what you want is to validate in some form the transformation parameters, some other method should be choosen, like bootstrapping. $\endgroup$ Commented Jul 2, 2018 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.