Bayesian Hyperparameter for Anfis

4 次查看(过去 30 天)
Raghu
Raghu 2021-6-26
编辑: Raghu 2021-6-29
Hello,
I tried developing codes for ANFIS for 2 inputs and 1 output using example provided by the Matlab. I would like to optimise it using the bayesian optimisation for hyperparameter tuning such as membership function and parameter tuning. Can someone please help me with that because the code is not working?
This is my code for the ANFIS:
Daten = rand(100, 3);
Daten(:,3) = Daten(:,1) + Daten(:,2) + .1*randn(100, 1);
[m,n] = size(Daten) ;
[m,n] = size(y) ;
% Split into train and test
P = 0.7 ;
Training = y(1:round(P*m),:) ;
Testing = y(round(P*m)+1:end,:);
XTrain = Training(:,1:n-1);
YTrain = Training(:,n);
XTest = Testing(:,1:n-1);
YTest = Testing(:,n);
%%
cv = cvpartition(numel(YTrain), 'Holdout', 1/3);
% Define hyperparameters to optimize
vars = [optimizableVariable('MF', [1,20], 'Type', 'integer');
optimizableVariable('EN', [1,100], 'Type', 'integer')];
% Optimize
minfn = @(vars)kfoldLoss(XTrain', YTrain', cv, vars.MF, vars.EN);
results = bayesopt(minfn, vars,'IsObjectiveDeterministic', false,...
'AcquisitionFunctionName', 'expected-improvement-plus');
vars = bestPoint(results);
% ANFIS model
a= Training % training data
x= [a(:,1),a(:,2)]; % input for anfis
opt = anfisOptions('InitialFIS',vars.MF,'EpochNumber',vars.EN);
opt.DisplayErrorValues = 0;
opt.DisplayStepSize = 0;
fis = anfis(y,opt);
anfisOutput= evalfis(fis,x);
z= anfisOutput;

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fuzzy Logic Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by