How to use Gaussian Process Regression with multidimension and covSEard?

12 次查看(过去 30 天)
How to use Gaussian Process Regression with multidimension and covSEard?
I have downloaded the Gaussian Processes for Machine Learning (GPML) package (gpml-matlab-v3.2-2013-01-15.zip) from the website. The demo_regression for one dimension works just fine in the matlab.
Now I have my own data for regression where the x (input) matrix is a 86x13 matrix (86 samples, 13 input vars), and the y (target) vector is 86x1. training data (58x13), test data(28x13), training target(58x1), test target(28x1)
The problem is that I do not understand hov to calculate the covfunc (covSEard), the code provided for the regression example does not work for multiple input datasets.
And the covSEiso works very well but I want to use covSEard because it is the best.
This is the error which appeared to me when I run the code:
.........................................................................
Error using eval Undefined function or variable 'D'.
Error in gpr (line 38) nhyp(i) = eval(feval(cov{2}{i}));
Error in minimize (line 75) [f0 df0] = feval(f, X, varargin{:}); % get function value and gradient
Error in GPR14_features_week5 (line 64) [logtheta0, fvals, iter] = minimize(logtheta0, 'gpr', -100, covfunc, NTData, NTargetT);
.....................................................................
Are there anybody who has tried this, and maybe can show an example?

回答(2 个)

Cameron LaMack
Cameron LaMack 2021-9-1
Hey there!
Hopefully you've had this question answered, but I saw that this has had a few views in the past 30 days so I thought I'd give an answer. So it's hard to tell without looking at your actual code, but the gpml toolbox is actually very friendly. It should be as easy as switching your covfunction from covSEiso to covSEard. The one thing you have to remember to do (which, based on the error, didn't end up happening), is initialize your hyperparameters to the correct size. It looks like you still only have 2 hyperparameters, which is fair, it's what the example problem has.
Rather you need 14 hyperparameters: 13 length scales for your input space of 13, and then one extra for signal variance (sf2).
Hope this helps whoever looks at this!

ubuntu21 T
ubuntu21 T 2023-1-20
Thanks @Cameron LaMack, please allow me to elaborate on what you said. @Weam, you will most likely need to have 2 lines of code which look like this:
covfunc = @covSEard; %squared exponential covariance function with automatic relevance determination (ARD)
%make sure to include the '@' sign in front of 'covSEard' otherwise I got an error "Invalid function name '(D+1)'"
hyp_ini = struct('mean', [], 'cov', [0 0 0 0 0 0 0 0 0 0 0 0 0 0], 'lik', -1); %the important part here is to have 14 parameters in the vector after 'cov'

Community Treasure Hunt

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

Start Hunting!

Translated by