optimizing GPR model using genetic algorithm

17 vues (au cours des 30 derniers jours)
Josh
Josh le 11 Juil 2022
Modifié(e) : Alan Weiss le 11 Juil 2022
As I tried to optimize the hyperparameters and sigma using GA, it is showing some error. Also, is it possible to limit the maximum
objective evaluations or put lb/ub on GA optimization? Please help.
clear;clc;close all
load('data001.mat')
x=data001(:,1);
y=data001(:,2);
kernel = optimizableVariable('KernelFunction',{'exponential','squaredexponential','matern32','matern52',...
'rationalquadratic','ardexponential','ardsquaredexponential','ardmatern32','ardmatern52','ardrationalquadratic'},...
'Type','categorical');
sigma = optimizableVariable('Sigma',[1e-4,10],'Transform','log');
go = ga(@objFcn,2) % calling objective function in optimization algorithm
kernel= go.XAtMinObjective.KernelFunction
model = fitrgp(x,y, 'KernelFunction', char(kernel));
yfit = predict(model, x);
function Loss = objFcn(Vars, x, y)
m = fitrgp(x, y, 'KernelFunction', char(Vars.KernelFunction), ...
'Sigma', Vars.Sigma, 'ConstantSigma', true,...
'KFold', 5);
Loss = kfoldLoss(m);
end
  1 commentaire
Alan Weiss
Alan Weiss le 11 Juil 2022
Modifié(e) : Alan Weiss le 11 Juil 2022
Alan Weiss
MATLAB mathematical toolbox documentation

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Problem-Based Optimization Setup dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by