-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfGPmodel.m
34 lines (29 loc) · 1.17 KB
/
InfGPmodel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [hyp_opt, NLML_opt, mPred, VarPred] = InfGPmodel(hyps, covfunc, lik, opt_num, xtrain, ytrain, xtest)
[xn, xD] = size(xtrain);
if xn>=1000
% train, Y is yes for normalizing
BCMopts.Xnorm = 'N' ; BCMopts.Ynorm = 'N' ; partitionCriterion = 'random' ;
BCMopts.Ms = floor(xn / 200); BCMopts.partitionCriterion = partitionCriterion ;
BCMopts.cov = hyps.cov ; BCMopts.covfunc = covfunc;
% opts.covfunc = @covSM;
BCMopts.likfunc = lik; BCMopts.inffunc = @infGaussLik; % @infGaussLik ;
BCMopts.numOptFC = opt_num; BCMopts.sn = hyps.lik; BCMopts.meanfunc = [];
criterion = 'RBCM' ;
[models, NLML_opt, hyp_opt, ~] = aggregation_train(xtrain, ytrain, BCMopts) ;
if nargin>6
[mPred, VarPred, ~] = aggregation_predict(xtest, models, criterion) ;
else
mPred = 0;
VarPred = 0;
end
else
hyp_opt = minimize(hyps, @gp, opt_num, @infExact, [], covfunc, lik, xtrain, ytrain);
NLML_opt = gp(hyp_opt, @infExact, [], covfunc, lik, xtrain, ytrain);
if nargin>6
[mPred, VarPred] = gp(hyp_opt, @infExact, [], covfunc, lik, xtrain, ytrain, xtest);
else
mPred = 0;
VarPred = 0;
end
end
end