1
$\begingroup$

Say you split your data into two sets: training and test sets. You know that the inputs of your data are in [lower_bounds, upper_bounds]. Now, assume that you would like to do a min-max normalization on your inputs between $[0, 1]$. For the values of the max and the min, should you use the min/max of your learning dataset or the bounds [lower_bounds, upper_bounds]?

In the same way, in order to normalize your test set, you should use the same bounds as the ones used for the learning dataset. If you use the min/max of your training set, some of your values in the test set can be found outside of $[0, 1]$, if, for instance, some values of the test set are greater than the max of the data in the learning dataset. Is it an issue?

$\endgroup$
3
  • 1
    $\begingroup$ Always scale with the values of the training set $\endgroup$
    – Peter
    Sep 8 at 21:18
  • $\begingroup$ Thank you. One more question: when you get your training data from an LHS (en.wikipedia.org/wiki/Latin_hypercube_sampling), do you use as min/max values the lower bounds/upper bounds used in the LHS or the min/max computed from the training data obtained? $\endgroup$
    – Akusa
    Sep 8 at 21:27
  • $\begingroup$ Not being familiar with LHS, I‘m actually not sure. I tend to say scale after LHS. Just try it. Ultimately scaling (based on the distribution of the train set) should improve the predictive power. Not using the test set (but scaling it instead on the basis of the min/max or whatever of the train set) simply is due to the fact that you cannot know the distribution of truly „new“ data in advance. $\endgroup$
    – Peter
    Sep 8 at 21:35
0
$\begingroup$

You pretend the out-of-sample data set does not exist. Any feature manipulations should be based on the in-sample (training) data.

If your in-sample data set is $\{1,2,3,4,5,6\}$ and your test set is $\{1,3,7\}$, you would do your normalization based on the in-sample set and accept that the $7$ in the test set will be normalized to a value exceeding $1$.

Remember that the reason we use a test set it to mimic the real use case where we make predictions on totally unseen data, perhaps even data that do not yet exist (think of Siri or Alexa being expected to do speech recognition for speech signals that have yet to be uttered, perhaps by people who have yet to be born).

$\endgroup$
3
  • $\begingroup$ Thank you. You mean "you would do your normalization based on the in-sample data set", not "on the test set", right? Moreover, say now that you used an LHS method to get your training data. To do so, you had to provide some lower bounds and upper bounds data. You know that these bounds will be different than the min/max of the obtained training data. Should you use the lower bounds/upper bounds provided in the LHS as min/max value or the true min/max computed from the training data? $\endgroup$
    – Akusa
    Sep 8 at 18:53
  • $\begingroup$ Typo corrected. // What do you mean by LHS? $\endgroup$
    – Dave
    Sep 8 at 19:00
  • $\begingroup$ I mean Latin Hypercube Sampling (en.wikipedia.org/wiki/Latin_hypercube_sampling) $\endgroup$
    – Akusa
    Sep 8 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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