簡體   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