Python统计模块:如何从GPy中提取置信度/预测区间?

Python统计模块:如何从GPy中提取置信度/预测区间?,python,statistics,confidence-interval,Python,Statistics,Confidence Interval,在浏览了所有在线文档和示例之后,我无法找到从模型中提取置信度或预测间隔信息的方法 我生成这样的虚拟数据 ## 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

在浏览了所有在线文档和示例之后,我无法找到从模型中提取置信度或预测间隔信息的方法

我生成这样的虚拟数据

## 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)
然后估计一个基本模型

## 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)

然而,没有任何东西明确说明如何从那里开始。。。另一个问题试图问同样的问题,但对于统计建模的如此重要的元素,该答案不再有效,而且似乎相当不令人满意。

给定一个模型和一组我们希望生成间隔的目标x值,您可以使用以下方法提取间隔:

intervals = model.predict_quantiles( X = target_x_vals, quantiles = (2.5, 97.5) )
您可以更改分位数参数以获得适当的宽度参数。此功能的文档可在以下位置找到: