what is the issue with my Fuzzy inference system (FIS) code?

12 visualizaciones (últimos 30 días)
Ahmad
Ahmad el 17 de Oct. de 2023
Respondida: Sam Chak el 18 de Oct. de 2023
am running the following code in matlab R2023b but it keeps returning the following error message:
Error using genfis
Invalid option sets.
Error in CreateInitialFIS (line 31)
fis = genfis(x, t, options);
Error in main (line 24)
fis=CreateInitialFIS(data,10);
The CreateInitialFIS.m code is:
function fis = CreateInitialFIS(data,nCluster)
if ~exist('nCluster', 'var')
nCluster = 'auto';
end
x = data.TrainInputs;
t = data.TrainTargets;
options = fcmOptions(...
NumClusters=nCluster,...
MaxNumIteration=100,...
MinImprovement=1e-5,...
Display=false);
% Create the FIS
fis = genfis(x, t, options);
end
The main.m code is:
%% Load Data
data=LoadData();
%% Generate Basic FIS
fis=CreateInitialFIS(data,10);
%% Train Using PSO
fis=TrainAnfisUsingPSO(fis,data);
%% Results
% Train Data
TrainOutputs=evalfis(data.TrainInputs,fis);
PlotResults(data.TrainTargets,TrainOutputs,'Train Data');
% Test Data
TestOutputs=evalfis(data.TestInputs,fis);
PlotResults(data.TestTargets,TestOutputs,'Test Data');

Respuesta aceptada

Sam Chak
Sam Chak el 18 de Oct. de 2023
The error is due to the incorrect usage of the option set. The option set for the genfis() function should be genfisOptions(), while fcmOptions() is the option set for the fcm() function.
%% Load Data
data = rand(100, 5);
%% Generate Basic FIS
fis = CreateInitialFIS(data, 10)
fis =
sugfis with properties: Name: "sugeno41" AndMethod: "prod" OrMethod: "probor" ImplicationMethod: "prod" AggregationMethod: "sum" DefuzzificationMethod: "wtaver" DisableStructuralChecks: 0 Inputs: [1×4 fisvar] Outputs: [1×1 fisvar] Rules: [1×10 fisrule] See 'getTunableSettings' method for parameter optimization.
function fis = CreateInitialFIS(data,nCluster)
if ~exist('nCluster', 'var')
nCluster = 'auto';
end
x = data(:,1:4);
t = data(:,5);
% options = fcmOptions(...
% NumClusters=nCluster,...
% MaxNumIteration=100,...
% MinImprovement=1e-5,...
% Verbose=false);
options = genfisOptions('FCMClustering', ...
NumClusters=nCluster, ...
MaxNumIteration=100, ...
MinImprovement=1e-5, ...
Verbose=false);
% Create the FIS
fis = genfis(x, t, options);
end

Más respuestas (1)

Adam Drake
Adam Drake el 17 de Oct. de 2023
Editada: Adam Drake el 17 de Oct. de 2023
The "Display" option should be "Verbose" according to the documentation for FCM clustering options.

Categorías

Más información sobre Fuzzy Inference System Tuning en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by