5

I have downloaded the Gaussian Processes for Machine Learning (GPML) package (gpml-matlab-v3.1-2010-09-27.zip) from the website, and I can run the regression example (demoRegression) in Octave. It works just fine.

Now I have my own data for regression where the x (input) matrix is a 54x10 matrix (54 samples, 10 input vars), and the y (target) vector is 54x1.

The problem is that I do not understand hov to calculate the meanfunc and the covfunc, the code provided for the regression example does not work for multiple input datasets.

I do not understand enough Octave to decode the specific code used to calculate this.

Are there anybody who has tried this, and maybe can show an example?

steadyfish
  • 1,772
  • 2
  • 15
  • 30
acorn_jens
  • 53
  • 1
  • 4

1 Answers1

8

Here is a more minimal example of a 2-d regression problem (I haven't got octave, only matlab, but hopefully the difference won't matter). meanfunc and covfunc should be happy with any number of inputs, provided that the covariance function doesn't have a hyper-parameter per inpit feature (as e.g. covSEiso does). Hope this helps

[X1,X2] = meshgrid(-pi:pi/16:+pi, -pi:pi/16:+pi);

Y = sin(X1).*sin(X2) + 0.1*randn(size(X1));

imagesc(Y); drawnow;

x = [X1(:) X2(:)];
y = Y(:);

covfunc = @covSEiso; 
  likfunc = @likGauss; sn = 0.1; hyp.lik = log(sn);

hyp2.cov = [0 ; 0];    
hyp2.lik = log(0.1);
hyp2 = minimize(hyp2, @gp, -100, @infExact, [], covfunc, likfunc, x, y);
exp(hyp2.lik)
nlml2 = gp(hyp2, @infExact, [], covfunc, likfunc, x, y)

[m s2] = gp(hyp2, @infExact, [], covfunc, likfunc, x, y, x);

m = reshape(m, size(Y));

figure(2); imagesc(m);
James
  • 103
  • 4
Dikran Marsupial
  • 46,962
  • 5
  • 121
  • 178
  • no problem, I have found GPML a great peice of kit, I thoroughly reccomend it to anyone wanting to investigate GPs. – Dikran Marsupial Mar 29 '11 at 15:37
  • What is the purpose of `sn = 0.1; hyp.lik = log(sn)` ? – Karel Macek Aug 06 '15 at 10:02
  • IIRC it is setting up an initial value for the (signal-to-) noise hyper-parameter of the GP. – Dikran Marsupial Aug 07 '15 at 07:00
  • @DikranMarsupial can you please explain why did you use the minimize function ? Is it to get the optimal hyper-parameters for the GP ? Also how is the choice of the mean and co-variance function done ? – roni Mar 28 '16 at 10:34
  • @DikranMarsupial Also in the second figure the contours seems to be a lot clearer - can you please give its meaning ... – roni Mar 28 '16 at 10:46
  • @roni yes minimise is used to tune the hyper-parameters of the covariance function. Deciding on the covariance function ought to be based on the properties of the regression function that we expect a-priori (e.g. stationarity, smoothness). Using linear or RBF covariance with zero mean function works reasonably well for most problems in the absence of better expert knowledge. I think the second figure is just a heat map of the regression function as a function of the inputs, the first is the noise data (I think). – Dikran Marsupial Mar 28 '16 at 14:07