필터 지우기
필터 지우기

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

조회 수: 5 (최근 30일)
Ahmad
Ahmad 2023년 10월 17일
답변: Sam Chak 2023년 10월 18일
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');

채택된 답변

Sam Chak
Sam Chak 2023년 10월 18일
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

추가 답변 (1개)

Adam Drake
Adam Drake 2023년 10월 17일
편집: Adam Drake 2023년 10월 17일
The "Display" option should be "Verbose" according to the documentation for FCM clustering options.

카테고리

Help CenterFile Exchange에서 Fuzzy Inference System Tuning에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by