Answers.Body: <p>Not sure about which function to call in GPFlow, but the principle is simple. If your <span class="math-container">$Y$</span> data was scaled:</p>
  <p><span class="math-container">$$Y_{scaled} = {(Y - mean(Y)) \over {sd(Y)}}$$</span></p>
  <p>So now if you have any prediction (from the scaled model) <span class="math-container">$\hat{Y}_{scaled}$</span>, with stand error <span class="math-container">$\sigma_{\hat {Y}_{scaled}}$</span>, then it is a normal distribution <span class="math-container">${\cal N}(\hat {Y}_{scaled}, \sigma^2_{\hat {Y}_{scaled}})$</span>. Then you can very easily rescale it back to the original scale <span class="math-container">${\cal N}(\hat {Y}, \sigma^2_{\hat {Y}})$</span>, where:</p>
  <p><span class="math-container">$$\hat {Y} = \hat {Y}_{scaled}\cdot sd(Y) + mean(Y)$$</span>
  <span class="math-container">$$\sigma_{\hat {Y}} = \sigma_{\hat {Y}_{scaled}} \cdot sd(Y)$$</span></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-13T03:51:45.757Z
Answers.LastActivityDate: 2021-01-13T03:51:45.757Z
Answers.UserDisplayName: Tomas
Body: <p>I trained some Gaussian process model with the Python library GPFlow on a dataset consisting of <span class="math-container">$(X, Y)$</span>, inputs and outputs, in a regression setting. This model gives me pretty good predictions in the sense that the relative error is small almost everywhere. I want to use the uncertainty as well, which is given in a GPFlow setting in the form of a standard deviation (STD) associated with every prediction. Here's my problem: I normalised both inputs and outputs before training (separately) using sklearn's StandardScaler (effectively making the data normally distributed with <span class="math-container">$0$</span> mean and unit STD). So the STD given by the model pertains to the scaled data. How do I "rescale" the uncertainty estimates of the GP to the actual data? Using the inverse_transform function of the output scaler makes little sense. This issue might be easier solvable if I scaled with a MinMaxScaler (squishing all data points into the unit interval) by dividing by the length of the range of the original output set (at least I think it works that way). But how about the case of the StandardScaler? Any insights will be appreciated!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-06T10:58:18.210Z
Comments.Text: I think it works by computing an interval of 1 STD around the predictions and then rescaling both interval boundaries, which should yield the corresponding interval on the original data set, irrespective of the way we scale.
Comments.UserDisplayName: Leon
Tags: <machine-learning><python>
Title: GPFlow: Gaussian Process Uncertainty Quantification
UserDisplayName: Leon
ThreadText: # GPFlow: Gaussian Process Uncertainty Quantification
  
  (Asked by: username_0 on 2019-02-06)
  
  I trained some Gaussian process model with the Python library GPFlow on a dataset consisting of $(X, Y)$, inputs and outputs, in a regression setting. This model gives me pretty good predictions in the sense that the relative error is small almost everywhere. I want to use the uncertainty as well, which is given in a GPFlow setting in the form of a standard deviation (STD) associated with every prediction. Here's my problem: I normalised both inputs and outputs before training (separately) using sklearn's StandardScaler (effectively making the data normally distributed with $0$ mean and unit STD). So the STD given by the model pertains to the scaled data. How do I "rescale" the uncertainty estimates of the GP to the actual data? Using the inverse\_transform function of the output scaler makes little sense. This issue might be easier solvable if I scaled with a MinMaxScaler (squishing all data points into the unit interval) by dividing by the length of the range of the original output set (at least I think it works that way). But how about the case of the StandardScaler? Any insights will be appreciated!
  
  **Tags:** machine-learning, python
  
  > **Comments:**
  > **username_0**: I think it works by computing an interval of 1 STD around the predictions and then rescaling both interval boundaries, which should yield the corresponding interval on the original data set, irrespective of the way we scale.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-13. Score: 1
  
  Not sure about which function to call in GPFlow, but the principle is simple. If your $Y$ data was scaled:
  
  $$Y\_{scaled} = {(Y - mean(Y)) \over {sd(Y)}}$$
  
  So now if you have any prediction (from the scaled model) $\hat{Y}\_{scaled}$, with stand error $\sigma\_{\hat {Y}\_{scaled}}$, then it is a normal distribution ${\cal N}(\hat {Y}\_{scaled}, \sigma^2\_{\hat {Y}\_{scaled}})$. Then you can very easily rescale it back to the original scale ${\cal N}(\hat {Y}, \sigma^2\_{\hat {Y}})$, where:
  
  $$\hat {Y} = \hat {Y}\_{scaled}\cdot sd(Y) + mean(Y)$$
  $$\sigma\_{\hat {Y}} = \sigma\_{\hat {Y}\_{scaled}} \cdot sd(Y)$$
  
  
  ---
  
  