Bayesian Hyperparameter for Anfis
3 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Fuzzy Logic Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!