How to make a 2D Gaussian process using GPML (Matlab) for regression?

I have an Nx2 input matrix called X. I also have output values โ€‹โ€‹of Y , which is a vector of Nx1. I create some data for testing as follows:

Xtest=linspace(x_min,x_max,n); Ytest=linspace(y_min,y_max,n); 

So, the matrix Z has dimensions nx2 and will be used as my test points. I am using the default setting of the parameters found in the demo provided using the GPML lib, which looks like this:

 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:

 [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. When I build it like this:

 [L1,L2]=meshgrid(Xtest',Ytest'); [mu,~]=meshgrid(ymu,ymu); surf(L1,L2,ymu); 

I get a weird surface. I get stripes of the color region, and not some Gaussian structure that is expected. The data in X and Y are real-life data. This is what I get from my code

What I expect: What i would expect

+3
source share
1 answer

You use it wrong. Your variable z must be given [L1 (:), L2 (:)]. Then you should do the following:

 surf(L1,L2,reshape(ymu,size(L1))); 
+3
source

Source: https://habr.com/ru/post/1262588/


All Articles