Use of fitrgp to solve simple example (Rasmussen book)

7 vues (au cours des 30 derniers jours)
Jose DELGADO
Jose DELGADO le 30 Oct 2016
Commenté : Jose DELGADO le 21 Mai 2017
I am learning Gaussian Processes and I am trying to replicate the canonical example of Rasmussen book. I understand it should be a simple application of fitrgp, but I cannot get it. I always get a flat response:
My idea is to have a very simple training set in a 2-D example
X=[1,3,7,10]';% those are the given points
y=[17,14,10,21]';% those are the expected responses
%Then I train a model
tbl=table(X,y);
grp=fitrgp(tbl,'y');
%and try to evaluate the fit for the interval [0,20]
xnew=linspace(0,20)';
[ypred,ysd]=predict(grp,xnew);
plot(xnew,ypred, xnew, ypred+ysd)
I was looking for something similar to Rasmussen result
But I only get a flat response
I have been looking in the web and I have found a example code that does the trick, but I understood that fitrgp should include and supersede it.
Am I correct?. Should I use some parameters with fitrgp different from the default? (I was reading/trying some of them carefully and I could not find the right combination)
Thank you in advance

Réponse acceptée

Gautam Pendse
Gautam Pendse le 20 Mai 2017
Hi Jose,
Function fitrgp fits the model by maximizing the marginal log likelihood. In some cases, there could be multiple local optima corresponding to different interpretations of the data. Consider initializing the noise standard deviation to a smaller value using the 'Sigma' name/value pair like this:
x = [-4;-2;-1;0;2];
y = [-2;0;1;2;-1];
gpr = fitrgp(x,y,'Sigma',0.1);
plot(x,y,'b+','DisplayName','Data');
hold on;
xtest = linspace(-5,5,1000)';
[pred,~,ci] = predict(gpr,xtest);
plot(xtest,pred,'r','DisplayName','Prediction');
hold on;
plot(xtest,ci(:,1),'c','DisplayName','Lower 95% Limit');
plot(xtest,ci(:,2),'k','DisplayName','Upper 95% Limit');
legend('show','Location','Best');
shg;
Also, have a look at this doc example which illustrates the effect of specifying initial parameter values to fitrgp:
Hope this helps,
Gautam
  1 commentaire
Jose DELGADO
Jose DELGADO le 21 Mai 2017
Thank you Gautam. The explanations on the help file are too short here
Thank you for your help and interest

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by