Answers.Body: <p>Okay, I figured it out by myself, simply by trial and error:</p>
  
  <p>When you normalize your training and test data, you also need to normalize the input you want to have a prediction for. You will also need to denormalize the result, to get a reasonable prediction.</p>
  
  <p>Specifically, in my case, this means:</p>
  
  <ul>
  <li>First I calculated the mean and the standard deviation, and then subtracted the mean and divided by standard deviation, to normalize my training and test data.</li>
  <li>So to normalize the input I want to have a prediction for, I also subtract the mean and divide by the standard deviation.</li>
  <li>Finally, when I get a result, I multiple by the standard deviation, and add the mean.</li>
  </ul>
  
  <p>This way, I get reasonable results </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-07T05:59:15.147Z
Answers.Text: Maybe it was just accidentally that the results after reverting the transformation made sense? What should I do instead?
Answers.UserDisplayName: Golo Roden
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-07T09:15:32.517Z
Answers.Text: Neural network with a single dense layer, with a single node using MSE and SGD. Just a really, really simple example.
Answers.UserDisplayName: Golo Roden
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-06T11:10:15.850Z
Answers.LastActivityDate: 2020-04-06T11:10:15.850Z
Answers.UserDisplayName: Golo Roden
Body: <p>I have learned so far how to linear regression with one or multiple features. So far, so good, everything seems to work fine, at least for my first simple examples.</p>
  <p>However, I now need to normalise my features for training. I'm doing this by calculating the mean and the standard deviation per feature, and then calculate the normalised feature by subtracting the mean, taking the absolute value, and dividing by the standard deviation. Again, so far, so good, the results of my tensors which I use for training look good.</p>
  <p>I understand why I need to normalise input data, and I also understand why one can do it like this (I know that there are other ways as well, e.g. to map values to a 0-1 interval).</p>
  <p>Now I was wondering about two things:</p>
  <ul>
  <li>First, after having trained my network, when I want to make a prediction for a specific input – do I need to normalise this as well, or do I use the un-normalised data? Does it make a difference? My gut feeling says, I <em>should</em> normalise it, as it <em>should</em> make a difference, but I'm not sure. What should I do here, and why?</li>
  <li>Second, either way, I get a result. Now I was wondering whether I need to denormalise this? I mean, it should make a difference, shouldn't it? If so, how? How do I get from the normalised result value to a denormalised one? Do I just need to reverse the calculation with mean and standard deviation, to get the actual value?</li>
  </ul>
  <p>It would be great if someone could shed some light on this.</p>
  
Tags: <machine-learning><data-preprocessing><linear-regression><normalisation>
Title: Do I need to denormalise results in linear regression?
UserDisplayName: Golo Roden
ThreadText: # Do I need to denormalise results in linear regression?
  
  (Asked by: username_0 on 2020-04-04)
  
  I have learned so far how to linear regression with one or multiple features. So far, so good, everything seems to work fine, at least for my first simple examples.
  
  However, I now need to normalise my features for training. I'm doing this by calculating the mean and the standard deviation per feature, and then calculate the normalised feature by subtracting the mean, taking the absolute value, and dividing by the standard deviation. Again, so far, so good, the results of my tensors which I use for training look good.
  
  I understand why I need to normalise input data, and I also understand why one can do it like this (I know that there are other ways as well, e.g. to map values to a 0-1 interval).
  
  Now I was wondering about two things:
  
  * First, after having trained my network, when I want to make a prediction for a specific input – do I need to normalise this as well, or do I use the un-normalised data? Does it make a difference? My gut feeling says, I *should* normalise it, as it *should* make a difference, but I'm not sure. What should I do here, and why?
  * Second, either way, I get a result. Now I was wondering whether I need to denormalise this? I mean, it should make a difference, shouldn't it? If so, how? How do I get from the normalised result value to a denormalised one? Do I just need to reverse the calculation with mean and standard deviation, to get the actual value?
  
  It would be great if someone could shed some light on this.
  
  **Tags:** machine-learning, data-preprocessing, linear-regression, normalisation
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-04-06. Score: 0 | Accepted answer
  
  Okay, I figured it out by myself, simply by trial and error:
  
  When you normalize your training and test data, you also need to normalize the input you want to have a prediction for. You will also need to denormalize the result, to get a reasonable prediction.
  
  Specifically, in my case, this means:
  
  * First I calculated the mean and the standard deviation, and then subtracted the mean and divided by standard deviation, to normalize my training and test data.
  * So to normalize the input I want to have a prediction for, I also subtract the mean and divide by the standard deviation.
  * Finally, when I get a result, I multiple by the standard deviation, and add the mean.
  
  This way, I get reasonable results
  
  > **Comments:**
  > **username_0**: Maybe it was just accidentally that the results after reverting the transformation made sense? What should I do instead?  
  > **username_0**: Neural network with a single dense layer, with a single node using MSE and SGD. Just a really, really simple example.  
  
  ---
  
  