Python统计模块: How to extract confidence/prediction intervals from GPy?

标签 python statistics confidence-interval gpy

在浏览完所有在线文档和示例后,我无法找到一种方法来从 GPy 中提取有关置信度或预测区间的信息。模型。

我生成这样的虚拟数据,

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

但是,没有什么可以清楚地说明如何从那里继续......另一个问题 here尝试问同样的问题,但对于统计建模如此重要的元素来说,这个答案不再有效,而且似乎相当令人不满意。

最佳答案

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

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

您可以更改分位数参数以获得适当的宽度。该函数的文档位于:https://gpy.readthedocs.io/en/deploy/_modules/GPy/core/gp.html

关于Python统计模块: How to extract confidence/prediction intervals from GPy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55927795/

相关文章:

c - 在 C 中生成整数的均匀分布

python - 如何在没有保证观测数量的情况下使用 Pandas 滚动平均值

r 使用 rms ols 函数处理多个对象和置信区间

matlab - 如何计算置信区间并将它们绘制在条形图上

python - 按升序将元素添加到已排序的数组中

python - Django:子类化 UserCreationForm:没有 get_user() 方法?

r - 分类变量的可能排列数

python - Tensorflow CUDA - CUPTI 错误 : CUPTI could not be loaded or symbol could not be found

python - 如何将参数传递给信号中的函数?

r - 提取 lmer 随机效应的置信区间;用 dotplot(ranef()) 绘制