Search code examples
machine-learningnormalization

Do you apply min max scaling separately on training and test data?


While applying min max scaling to normalize your features, do you apply min max scaling on the entire dataset before splitting it into training, validation and test data?

Or do you split first and then apply min max on each set, using the min and max values from that specific set?

Lastly , when making a prediction on a new input, should the features of that input be normalized using the min, max values from the training data before being fed into the network?


Solution

  • Split it, then scale. Imagine it this way: you have no idea what real-world data looks like, so you couldn't scale the training data to it. Your test data is the surrogate for real-world data, so you should treat it the same way.

    To reiterate: Split, scale your training data, then use the scaling from your training data on the testing data.