How can I use a trained gaussian process inside a function to calculate predictions for the inputs of the function?

1 vue (au cours des 30 derniers jours)
I have a trained Gaussian Process regression on a set of data. I want to use this trained GP model inside another function to predict new outcomes whenever the function is called in another code, without having to train a GP model inside the function whenever it is called.
gpMdl=fitrgp(xtrn,ytrn); % this is the trained GP model
Now I want to use it for a function like following:
function Y=myfunc(Xnew)
yp=predict(gpMdl,Xnew); % predict based on the previously trained GP model
Y=1-exp(yp); % do something on the prediction and produce results
end
The function is then called somewhere else, for example:
% some code to give "some_data"
tp=some_data; % this is produced in the code
for i=numel(tp)
myfunc(tp(i));
end

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by