Scaling training and cross validation set

In the W3 first lab why is scaling applied only to the training set and then the mean and standard deviation values are used in the cross-validation set, instead of scaling the entire dataset (train + test + cross) and using the mean and standard deviation values for all partitions?

Hello @Cristhian_David_Pere,

Though it is not usual to hear, you might consider those scaling factors part of your trained model - that they shouldn’t be contributed by anything but the training set which makes the trained model. When you pick the best model with the cross validation, you also pick the corresponding scaling factors.

Besides, keeping the validation and test data out mimics production data which shouldn’t be available to your model training process.

Cheers,
Raymond