问题描述
sklearn python 包 GaussianProcessRegressor (GPR) 拟合了 n_samples
样本的数据和训练集 n_features
和目标 X
的 y
特征。预测例程 (predict
) 返回预测值及其相关的标准差,可以使用这些标准差将误差线绘制到 y
点(参见 {{3} }).
然而,sklearn 教程并未涵盖具有多个目标的训练数据示例。在这种情况下,fill_between
始终为每个样本返回一个标准偏差值。我不知道如何将这个单一的标准偏差转换为我必须关联到每个预测目标的多个误差线。
这是我的最小工作示例:
predict
哪个打印
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import RBF,ConstantKernel as C,ConstantKernel,Exponentiation
n_samples = 43
n_features = 5
n_targets = 3
X = [
[i]*n_features for i in range(n_samples)
]
y = [
[ i* j for j in range(n_targets) ] for i in range(n_samples)
]
gp = GaussianProcessRegressor(kernel = C(1.) * RBF(.1),normalize_y=True,n_restarts_optimizer=10)
# please don't mind the bad kernel choise or the triviality of X and y
# as here I only want to retrive their numpy shape
gp.fit(X,y)
# test the model
X0 = [[1,2,3,4,5]]
y0,y0std = gp.predict(X0,return_std=True)
print(y0.shape,y0std.shape)
这意味着我得到了三个预测目标(如 (1,3) (1,)
),但是我只得到了一个标准差!
所以我的问题是:我不应该为三个目标获得三个不同的标准偏差吗?而且,如果我得到的值是正确的,我如何将不同的错误关联到每个不同的目标?例如,如何在绘制数据时计算误差条大小?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)