scikit高斯过程回归的非自然预测

时间:2019-11-20 06:24:33

标签: python machine-learning scikit-learn regression

我正在尝试使用高斯过程回归并使用scikit的“ gaussian_process”库来运行一个简单的回归问题以适合我的模型。但是,该模型提供了不自然的错误预测。这是我的数据和代码的摘要-

首先,这是训练数据-

plt.figure()
plt.scatter(t, y, c='g', label='actual')
plt.show()

Training Data

这是我用于运行高斯过程回归的代码。

kernel = C(1.0, (1e-1, 1e3)) * RBF(length_scale=1.0, length_scale_bounds=(1e-2, 1e5))
gp = GaussianProcessRegressor(kernel=kernel,n_restarts_optimizer=50,normalize_y=True)
gp.fit(np.asarray(t).reshape(-1,1),np.asarray(y))
#generate test data within the same range for prediction
x = np.linspace(min(t), max(t), 100)
y_pred, sigma = gp.predict(x.reshape(-1,1), return_cov=True)
#generate 95% confidence bound
yTop = y_pred + np.sqrt(np.diag(sigma))
yBottom = y_pred - np.sqrt(np.diag(sigma))
#plot results
plt.figure()
plt.scatter(x, y_pred, c='r', label='Prediction')
plt.fill_between(x,yBottom,yTop,alpha=0.5, color='k')
plt.show()

以某种方式产生此- Predictions

这是同一张图片的放大版本- enter image description here

不仅预测偏离了,而且还有负面预测。有什么问题的帮助吗?我也尝试过重新缩放RBF内核,但这会产生相同的输出。

0 个答案:

没有答案