[英]How to make a 2D Gaussian Process using GPML (Matlab) for regression?
I have an Nx2 input matrix called X . 我有一个名为X的Nx2输入矩阵。 I also have the output values Y which is a vector Nx1 .
我也有输出值Y ,它是矢量Nx1 。 I create some data to test as follows:
我创建了一些数据来测试如下:
Xtest=linspace(x_min,x_max,n);
Ytest=linspace(y_min,y_max,n);
So, matrix Z is of nx2 dimensions and is going to be used as my test points. 因此,矩阵Z具有nx2维度,并将用作我的测试点。 I use the default tuning of the parameters found in the demo provided with the GPML lib which is as follows:
我使用GPML lib提供的演示中的参数的默认调整,如下所示:
covfunc = {@covMaterniso, 3};
ell = 1/4; sf = 1;
hyp.cov = log([ell; sf]);
likfunc = @likGauss;
sn = 0.1;
hyp.lik = log(sn);
and then use the gp function: 然后使用gp函数:
[ymu ys2 fmu fs2] = gp(hyp, @infExact, [], covfunc, likfunc, x, y, z);
I expected ymu to be the predicted value for each testing value in z. 我希望ymu是z中每个测试值的预测值。 When I plot this like this:
当我这样绘制时:
[L1,L2]=meshgrid(Xtest',Ytest');
[mu,~]=meshgrid(ymu,ymu);
surf(L1,L2,ymu);
I get a strange surface. 我得到一个奇怪的表面。 ie i get stripes of coloured area rather some Gaussian like structure which is expected.
即我得到彩色区域的条纹,而不是一些预期的高斯式结构。 The data in X and Y are real life data.
X和Y中的数据是实际数据。
What I would expect: 我期待的是:
You're using it wrong. 你错了。 Your z variable should be given by [L1(:),L2(:)].
你的z变量应该由[L1(:),L2(:)]给出。 Then what you should plot is:
然后你应该绘制的是:
surf(L1,L2,reshape(ymu,size(L1)));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.