1

After having looked through all the docs and examples online, I have not been able to find a way to extract information regarding the confidence or prediction intervals from GPy models.

I generate dummy data like this,

## Generating data for regression
# First, regular sine wave + normal noise
x = np.linspace(0,40, num=300)
noise1 = np.random.normal(0,0.3,300)
y = np.sin(x) + noise1

## Second, an upward trending starting midway, with its own noise as well
temp = x[150:]
noise2 = 0.004*temp**2 + np.random.normal(0,0.1,150)
y[150:] = y[150:] + noise2

plt.plot(x, y)

and then estimate a basic model,

## Pre-processing
X = np.expand_dims(x, axis=1)
Y = np.expand_dims(y, axis=1)

## Model
kernel = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.)
model1 = GPy.models.GPRegression(X, Y, kernel)

However, nothing makes it clear how to proceed from there... Another question here tried asking the same thing, but that answer does not work any more, and seems rather unsatisfactory, for such an important element of statistical modelling.

gehbiszumeis
  • 3,525
  • 4
  • 24
  • 41
Coolio2654
  • 1,589
  • 3
  • 21
  • 46

1 Answers1

2

Given a model, and a set of target x values we want to generate the intervals at, you can extract the intervals using:

intervals = model.predict_quantiles( X = target_x_vals, quantiles = (2.5, 97.5) )

You can change the quantiles argument to get the appropriate width ones. The documentation for this function is found at: https://gpy.readthedocs.io/en/deploy/_modules/GPy/core/gp.html

Kieran108
  • 99
  • 10