繁体   English   中英

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

[英]Python stats module: How to extract confidence/prediction intervals from 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)

但是,没有什么东西使如何从那里开始变得很清楚。 这里的另一个问题试图问同样的问题,但是对于如此重要​​的统计建模元素,该答案不再起作用,并且似乎还不能令人满意。

给定一个模型以及我们要生成间隔的一组目标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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM