fitrgp function: problem with custom kernel
13 views (last 30 days)
Show older comments
Hi all,
I am trying to train a Gaussian Process model with the function fitrgp, using a custom kernel. A matrix dimension problem appears when computing, and I'm not able to resolve it.
I reproduce the ARD-squared exponential kernel for the example:
This is my code:
if true
kernel = @(xp,xq,theta) theta(8).^2 * exp(-1/2 * sum( ...
((xp(1, 1:(length(theta)-1)) - xq(1, 1:(length(theta)-1))) .^2) ...
./ (theta(1, 1:(length(theta)-1)) .^2)));
theta0 = [5, 2000, 20, 10, 40, 0.5, 0.5, 0.1];
GP_model = fitrgp(training_table,'CELLS_Delta_Q_shft_large', 'Basis','none','KernelFunction',kernel,'KernelParameters',theta0,...
'FitMethod','exact','PredictMethod','exact');
end
'training_table' is a 910x8 table, and 'CELLS_Delta_Q_shft_large' is the name of the last column.
The error specifies:
if true
Index exceeds matrix dimensions.
Error in
@(xp,xq,theta)theta(8).^2*exp(-1/2*sum(((xp(1,1:(length(theta)-1))-xq(1,1:(length(theta)-1))).^2)./(theta(1,1:(length(theta)-1)).^2)))
Error in classreg.learning.gputils.CustomKernel/makeKernelAsFunctionOfTheta/f (line 138)
KNM = customFcn(XN,XM,theta);
Error in classreg.learning.impl.GPImpl/makeNegativeProfiledLogLikelihoodExact/f1 (line 970)
[V,DK] = kfcn(theta);
Error in classreg.learning.gputils.fminqn (line 199)
f = fun(x);
Error in classreg.learning.impl.GPImpl/doMinimization (line 3007)
[phiHat,fHat,~,exitFlag] = classreg.learning.gputils.fminqn(objFun,phi0,'Options',opts);
Error in classreg.learning.impl.GPImpl/estimateThetaHatSigmaHatExact (line 855)
[phiHat,nloglikHat,cause] = doMinimization(this,objFun,phi0,haveGrad);
Error in classreg.learning.impl.GPImpl/doFitMethodExact (line 422)
[this.ThetaHat,this.SigmaHat,this.LogLikelihoodHat] =
estimateThetaHatSigmaHatExact(this,this.X,this.y,this.Beta0,this.Theta0,this.Sigma0);
Error in classreg.learning.impl.GPImpl/doFit (line 362)
this = doFitMethodExact(this);
Error in classreg.learning.impl.GPImpl.make (line 264)
this = doFit(this);
Error in RegressionGP (line 277)
this.Impl = classreg.learning.impl.GPImpl.make(...
Error in classreg.learning.FitTemplate/fit (line 258)
[varargout{1:nargout}] = this.MakeFitObject(X,Y,W,this.ModelParams,fitArgs{:});
Error in RegressionGP.fit (line 305)
this = fit(temp,X,Y);
Error in fitrgp (line 493)
obj = RegressionGP.fit(X,Y,RemainingArgs{:});
end
Do you have any idea about what I'm doing wrong?
Thank you
0 Comments
Answers (0)
See Also
Categories
Find more on Gaussian Process Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!