Filter löschen
Filter löschen

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

5 Ansichten (letzte 30 Tage)
Ahmad
Ahmad am 17 Okt. 2023
Beantwortet: Sam Chak am 18 Okt. 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');

Akzeptierte Antwort

Sam Chak
Sam Chak am 18 Okt. 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

Weitere Antworten (1)

Adam Drake
Adam Drake am 17 Okt. 2023
Bearbeitet: Adam Drake am 17 Okt. 2023
The "Display" option should be "Verbose" according to the documentation for FCM clustering options.

Kategorien

Mehr zu Fuzzy Inference System Tuning finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by