如何使用GPML(Matlab)进行二维高斯过程回归? [英] How to make a 2D Gaussian Process using GPML (Matlab) for regression?
问题描述
我有一个名为 X 的 Nx2 输入矩阵.我还有输出值 Y ,它是向量 Nx1 .我创建一些数据进行测试,如下所示:
I have an Nx2 input matrix called X. I also have the output values Y which is a vector Nx1. I create some data to test as follows:
Xtest=linspace(x_min,x_max,n);
Ytest=linspace(y_min,y_max,n);
因此,矩阵 Z 的尺寸为 nx2 ,将用作我的测试点.我使用与GPML lib一起提供的演示中找到的参数的默认调整,如下所示:
So, matrix Z is of nx2 dimensions and is going to be used as my test points. I use the default tuning of the parameters found in the demo provided with the GPML lib which is as follows:
covfunc = {@covMaterniso, 3};
ell = 1/4; sf = 1;
hyp.cov = log([ell; sf]);
likfunc = @likGauss;
sn = 0.1;
hyp.lik = log(sn);
,然后使用gp函数:
[ymu ys2 fmu fs2] = gp(hyp, @infExact, [], covfunc, likfunc, x, y, z);
我希望ymu是z中每个测试值的预测值.当我这样绘制时:
I expected ymu to be the predicted value for each testing value in z. When I plot this like this:
[L1,L2]=meshgrid(Xtest',Ytest');
[mu,~]=meshgrid(ymu,ymu);
surf(L1,L2,ymu);
我得到一个奇怪的表面.即我得到了彩色区域的条纹,而不是预期的某种高斯式结构. X 和 Y 中的数据是真实数据.
I get a strange surface. i.e i get stripes of coloured area rather some Gaussian like structure which is expected. The data in X and Y are real life data.
我期望的是:
推荐答案
您使用的是错误的.您的z变量应由[L1(:),L2(:)]给出.那么您应该绘制的是:
You're using it wrong. Your z variable should be given by [L1(:),L2(:)]. Then what you should plot is:
surf(L1,L2,reshape(ymu,size(L1)));
这篇关于如何使用GPML(Matlab)进行二维高斯过程回归?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!