the neuro fuzzy sistem modify the membership function in input or in output?

2 views (last 30 days)
Hello, I wanted to understand what happens to the membership function (in input/output) or rules when I insert in the anfis editor: Sugeno file and a training set.

Answers (1)

Sam Chak
Sam Chak on 28 Sep 2024
In the following simple example, the ANFIS is trained to fit a trapezoidal set-based fuzzy system to the input/output data of an ideal saturation function. We can clearly observe that both the initial trapezoidal input membership function (MF) and the constant output MF are slightly different from the final trapezoidal input MF and constant output MF. ANFIS will update the parameters of both the input and output membership functions.
%% data
x = (-1:0.01:1)';
y = min(max(-5*x, -1), 1); % <-- ideal saturation function
genOpt = genfisOptions('GridPartition');
genOpt.NumMembershipFunctions = 2;
genOpt.InputMembershipFunctionType = 'trapmf';
genOpt.OutputMembershipFunctionType = 'constant';
inFIS = genfis(x,y,genOpt);
showrule(inFIS)
ans = 2x53 char array
'1. If (input1 is in1mf1) then (output is out1mf1) (1)' '2. If (input1 is in1mf2) then (output is out1mf2) (1)'
opt = anfisOptions('InitialFIS', inFIS, 'EpochNumber', 50);
opt.DisplayANFISInformation = 0;
opt.DisplayErrorValues = 0;
opt.DisplayStepSize = 0;
opt.DisplayFinalResults = 0;
outFIS = anfis([x y],opt);
%% plot result
figure
subplot(211)
plotmf(inFIS, 'input', 1), grid on
title('inFIS Input Fuzzy Sets')
subplot(212)
plot(x, [y, evalfis(inFIS, x)]), grid on, ylim([-1.2, 1.2])
title('Compare Data with Untrained ANFIS Output')
legend('Data', 'Untrained ANFIS Output')
inFIS.inputs(1).MembershipFunctions(1).Name
ans = "in1mf1"
inFIS.inputs(1).MembershipFunctions(1).Type
ans = "trapmf"
inFIS.inputs(1).MembershipFunctions(1).Parameters
ans = 1×4
-2.4000 -1.6000 -0.4000 0.4000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
inFIS.Outputs(1).MembershipFunctions(1).Name
ans = "out1mf1"
inFIS.Outputs(1).MembershipFunctions(1).Type
ans = "constant"
inFIS.Outputs(1).MembershipFunctions(1).Parameters
ans = 0
figure
subplot(211)
plotmf(outFIS, 'input', 1), grid on
title('outFIS Input Fuzzy Sets')
subplot(212)
plot(x, [y, evalfis(outFIS, x)]), grid on, ylim([-1.2, 1.2])
title('Compare Data with Trained ANFIS Output')
legend('Data', 'Trained ANFIS Output')
outFIS.inputs(1).MembershipFunctions(1).Name
ans = "in1mf1"
outFIS.inputs(1).MembershipFunctions(1).Type
ans = "trapmf"
outFIS.inputs(1).MembershipFunctions(1).Parameters
ans = 1×4
-2.4000 -1.6000 -0.4000 0.1997
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
outFIS.Outputs(1).MembershipFunctions(1).Name
ans = "out1mf1"
outFIS.Outputs(1).MembershipFunctions(1).Type
ans = "constant"
outFIS.Outputs(1).MembershipFunctions(1).Parameters
ans = 0.9999

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!