issue with the output

5 views (last 30 days)
Reen Blake-Carr
Reen Blake-Carr on 17 Aug 2020
Commented: Walter Roberson on 18 Aug 2020
Hi there i have been building a fuzzy inference system for the pima indians dataset which uses the triangular membership fucntions as seen below now they require three inputs as it is known and i have used these inputs from the basis of a decision tree i have created i am currently experiencing some kind of issue with the rule base now i have written the rules using a symbolic matrix format but i do keep getting this error when i try to use the 2nd rule using the eval function the error is when im trying to use the eval function for rule 2 it seems to jump to input 5 which i dont understand and i have tried everything to try to get it working but i am unable to and to which it gives me this warning to which there is a rule base and a range to which it should folllow and i have tried everything to try to get this working i am really new at this software and so im not very good at working the error codes and the code itself out yet so i am asking would anyone be able to help me solve these warnings as i need to get them done.
below is a excerpt of my code
any help given is grealty appreciated
Warning: Input 5 expects a value in range [0 1], but has a value of 2.
Warning: No rules fired for Output 1. Defuzzified output value set to its mean range value 0.5.
fis = mamfis('Name', "PimaIndians");
fis = addInput(fis,[0 160], 'Name',"Glucose");
fis = addmf(fis,"Glucose","trimf",[0 40 99],'Name',"low");
fis = addmf(fis,"Glucose","trimf",[99 110 127],'Name',"medium");
fis = addmf(fis,"Glucose","trimf",[127 140 157],'Name',"High");
fis = addInput(fis,[0 30],'Name',"BMI");
fis = addmf(fis,"BMI","trimf",[26 26.2 26.4],'Name',"low");
fis = addmf(fis,"BMI","trimf",[28 28.6 28.8],'Name',"medium");
fis = addmf(fis,"BMI","trimf",[29.3 29.6 29.9],'Name',"High");
fis = addInput(fis,[0 61],'Name',"BloodPressure");
fis = addmf(fis,"BloodPressure","trimf",[10 20 30],'Name',"low");
fis = addmf(fis,"BloodPressure","trimf",[30 40 45],'Name',"Medium");
fis = addmf(fis,"BloodPressure","trimf",[50 55 61],'Name',"High");
fis = addInput(fis,[0 30],'Name',"Age");
fis = addmf(fis,"Age","trimf",[0 5 10],'Name',"low");
fis = addmf(fis,"Age","trimf",[10 15 20],'Name',"medium");
fis = addmf(fis,"Age","trimf",[20 25 30],'Name',"High");
fis = addInput(fis,[0 1],'Name',"DiabetesFunction");
fis = addmf(fis,"DiabetesFunction","trimf",[0 0.1 0.2],'Name',"low");
fis = addmf(fis,"DiabetesFunction","trimf",[0.2 0.3 0.4],'Name',"medium");
fis = addmf(fis,"DiabetesFunction","trimf",[0.4 0.5 0.6],'Name',"High");
fis = addInput(fis,[0 6],'Name',"Pregnancies");
fis = addmf(fis,"Pregnancies","trimf",[0 1 2],'Name',"low");
fis = addmf(fis,"Pregnancies","trimf",[2 3 4],'Name',"medium");
fis = addmf(fis,"Pregnancies","trimf",[4 5 6],'Name',"high");
fis = addInput(fis,[0 30],'Name',"Insulin");
fis = addmf(fis,"Insulin","trimf",[0 5 10],'Name',"low");
fis = addmf(fis,"Insulin","trimf",[10 15 20],'Name',"medium");
fis = addmf(fis,"Insulin","trimf",[20 25 30],'Name',"High");
fis = addOutput(fis,[0 1],'Name',"Diabetes");
fis = addmf(fis,"Diabetes","trimf",[0 0.2 0.4],'Name',"NoDiabetes");
fis = addmf(fis,"Diabetes","trimf",[0.5 0.6 0.7],'Name',"HasDiabetes");
Rule1 = "Glucose==medium => Diabetes=NoDiabetes"
Rule2 = "BMI==low => Diabetes=NoDiabetes"
Rule3 = "BMI==High & Glucose==High => Diabetes=HasDiabetes"
Rule4 = "BloodPressure==low => Diabetes=NoDiabetes"
Rule5 = "BloodPressure==High & Age==low => Diabetes=NoDiabetes"
Rule6 = "BloodPressure==High & Age==High => Diabetes=HasDiabetes"
Rule7 = "Glucose==medium & BMI==low => Diabetes=NoDiabetes"
Rule8 = "BMI==low & Age==low => Diabetes=NoDiabetes"
Rule9 = "Age==medium & Glucose==low => Diabetes=NoDiabetes"
Rule10 = "Glucose==low & DiabetesFunction==low => Diabetes=NoDiabetes"
Rule11 = "DiabetesFunction==High & Pregnancies==high => Diabetes=HasDiabetes"
Rule12 = "Pregnancies==low & Insulin==low => Diabetes=NoDiabetes"
Rule13 = "Pregnancies==medium & Insulin==High => Diabetes=HasDiabetes"
Rules = [Rule1 Rule2 Rule3 Rule4 Rule5 Rule6 Rule7 Rule8 Rule9 Rule10 Rule11 Rule12 Rule13]
fis = addRule(fis,Rules)
evalfis(fis,[2])
  1 Comment
Walter Roberson
Walter Roberson on 17 Aug 2020
You need to pass inputs to evalfis not rule numbers

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 18 Aug 2020
You have a fis with 7 inputs and 1 output. When you ask to
evalfis(fis, [2])
you are passing in one input instead of 7 inputs. That syntax does not ask that rule #2 be evaluated or displayed: it says that you want 2 to be the input for your entire system.
Now there are several different ways that evalfis could react when you pass in a scalar instead of the seven different inputs. The way that it happens to react is as if you had passed in the scalar for each of the inputs, so like
evalfis(fis, repmat(2,1,7))
However your 5th input, Diabetes Function, is only permitted to be in the range 0 to 1, so it ignores the 2 and treats it as half way through the valid range, 0.5
  1 Comment
Walter Roberson
Walter Roberson on 18 Aug 2020
There is no tool to exercise a particular fis rule given the rule number.

Sign in to comment.

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!