2
$\begingroup$

From reading some answers on this site (1, 2, 3 and 4) I found that, on time series data, standardization must be applied separately on the train and test sets to avoid data leakage.

So the train data would be standardized using a different mean than the test set. This makes sense as the mean of the train would be present in the test.

However, in the video Normalizing inputs at about 1:40 Prof. Andrew Ng mentions that the same mean and standard deviation should be used for both the train and test sets. Although the data was not a time series in the example it still contradicts the advice given on this site.

What is the main difference when standardizing time series and non-time series data? Why is there a difference?

$\endgroup$

1 Answer 1

2
$\begingroup$

I've read all the mentioned answers there but they all agree on not standardizing training and test sets together because it'd cause data leakage. This means, any standardisation coefficient, e.g. min/max, median, mean, IQR, std is estimated from the training set and applied on the test set. This is in line with what Prof. Andrew Ng says. Some quotes from them:

Second:

Also for the sake of example say you have 10 years of data and you want to train your model on the first 9 years and test on the last year. When you standardize, you should only standardize over data from the first 9 years.

Fourth:

Formally speaking, for the prediction of 𝑦𝑡16 and onwards, there is no leakage because the standardisation does not include information that would be unavailable at the time of prediction.

The third one isn't about normalization. The first one seems a bit vague. There is trend in the time series and the advice is to take the first difference to get rid of it. The standardisation applied in the original question is correct. The answer also says the following, which means the OP shouldn't standardize using the entire dataset:

Don't standardize on the entire dataset (that's leaking data, and I think it's cheating).

$\endgroup$

Your Answer

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

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