IF-THEN RULES AND FUZZY INFERENCEsite.iugaza.edu.ps › mahir › files › 2010 › 02 ›...
Transcript of IF-THEN RULES AND FUZZY INFERENCEsite.iugaza.edu.ps › mahir › files › 2010 › 02 ›...
IFIF--THEN RULES THEN RULES ANDAND
FUZZY INFERENCEFUZZY INFERENCE
inference\In"fer*ence\, n. [From Infer.]
1. The act or process of inferring by deduction or induction.
2. That which inferred; a truth or proposition drawn from another which is admitted or supposed to be true; a conclusion; a deduction. --Milton.
Inference is a process of obtaining new knowledge through existing knowledge.
inferenceinference\\In"ferIn"fer**enceence\\, n. [From , n. [From InferInfer.] .]
1. The act or process of inferring by 1. The act or process of inferring by deduction or induction.deduction or induction.
2. That which inferred; a truth or 2. That which inferred; a truth or proposition drawn from another which is proposition drawn from another which is admitted or supposed to be true; a admitted or supposed to be true; a conclusion; a deduction. conclusion; a deduction. ----Milton. Milton.
Inference is a process of obtaining new Inference is a process of obtaining new knowledge through existing knowledge.knowledge through existing knowledge.
InferenceInference
Representation of knowledgeRepresentation of knowledgeTo perform inference, knowledge should To perform inference, knowledge should be represented in some form be represented in some form
Representation of knowledge as rules is the most Representation of knowledge as rules is the most popular form. popular form.
if x is A then y is Bif x is A then y is B(where (where AA and and BB are linguistic values defined by fuzzy are linguistic values defined by fuzzy sets on universes of discourse sets on universes of discourse XX and and YY).).
A rule is also called a A rule is also called a fuzzy implication fuzzy implication ““x is Ax is A”” is called the is called the antecedentantecedent or or premise premise ““y is By is B”” is called the is called the consequenceconsequence or or conclusionconclusion
http://if.kaist.ac.kr/lecture/cs670/textbook/
Representation of knowledgeRepresentation of knowledge
Examples:Examples:
If pressure is high, then volume is small. If pressure is high, then volume is small. If the road is slippery, then driving is If the road is slippery, then driving is dangerous. dangerous. If an apple is red, then it is ripe. If an apple is red, then it is ripe. If the speed is high, then apply the brake aIf the speed is high, then apply the brake alittle.little.
http://if.kaist.ac.kr/lecture/cs670/textbook/
Knowledge as RulesKnowledge as RulesHow do you reason? How do you reason? –– You want to play golf on Saturday or Sunday You want to play golf on Saturday or Sunday
and you donand you don’’t want to get wet when you play. t want to get wet when you play. Use rules! Use rules! –– If it rains, you get wet! If it rains, you get wet! –– If you get wet, you canIf you get wet, you can’’t play golf t play golf If it rains on Saturday and wonIf it rains on Saturday and won’’t rain on t rain on Sunday Sunday –– You play golf on SundayYou play golf on Sunday!!*Fuzzy Thinking:The new Science of Fuzzy Logic, Bart Kosko
Knowledge is rules Knowledge is rules Rules are in blackRules are in black--andand--white language white language –– Bivalent rules Bivalent rules AI has so far, after over 30 years of AI has so far, after over 30 years of research, not produced smart machines! research, not produced smart machines! –– Because they canBecause they can’’t yet put enough rules in the t yet put enough rules in the
computer (use 100computer (use 100--1000 rules, need >100k} 1000 rules, need >100k} –– Throwing more rules at the problem Throwing more rules at the problem
*Fuzzy Thinking:The new Science of Fuzzy Logic, Bart Kosko
Knowledge as RulesKnowledge as Rules
Forms of reasoningForms of reasoning
Generalized Modus Generalized Modus PonensPonens::
Premise:Premise: xx is Ais A’’Implication:Implication: if if xx is A then is A then yy is Bis BConsequence:Consequence: yy is Bis B’’
Where Where A, AA, A’’, B, B, B, B’’ are fuzzy sets and are fuzzy sets and xx and and yyare symbolic names for objects.are symbolic names for objects.
http://if.kaist.ac.kr/lecture/cs670/textbook/
Forms of reasoningForms of reasoning
Generalized Modus Generalized Modus TolensTolens::
Premise:Premise: yy is Bis B’’Implication:Implication: if if xx is A then is A then yy is Bis BConsequence:Consequence: xx is Ais A’’
Where Where A, AA, A’’, B, B, B, B’’ are fuzzy sets andare fuzzy sets and xx and and yyare symbolic names for objects.are symbolic names for objects.
http://if.kaist.ac.kr/lecture/cs670/textbook/
Fuzzy rule as a relationFuzzy rule as a relation
if x is A then y is Bif x is A then y is B““x is Ax is A””, , ““y is By is B”” –– fuzzy predicates fuzzy predicates A(xA(x), ), B(yB(y))
if if A(xA(x) then ) then B(yB(y) ) can be represented as a relation can be represented as a relation
R(x,yR(x,y): ): A(xA(x) ) →→ B(yB(y) ) where where R(x,yR(x,y)) can be considered a fuzzy set can be considered a fuzzy set
with 2with 2--dimentional membership function dimentional membership function µµRR(x,y(x,y)=)=f(f(µµAA(x),(x),µµBB(y(y)) ))
where where ff is is fuzzy implication functionfuzzy implication functionhttp://if.kaist.ac.kr/lecture/cs670/textbook/
MIN fuzzy implicationMIN fuzzy implication
Interprets the fuzzy implication as the minimum operation [Mamdani]. Interprets the fuzzy implication as the minimum operation [Mamdani].
http://if.kaist.ac.kr/lecture/cs670/textbook/
PRODUCT fuzzy implicationPRODUCT fuzzy implication
Interprets the fuzzy implication as the product operation [Larsen]. Interprets the fuzzy implication as the product operation [Larsen].
http://if.kaist.ac.kr/lecture/cs670/textbook/
EXAMPLE OF FUZZY EXAMPLE OF FUZZY IMPLICATIONIMPLICATION
Fuzzy rule: “If temperature is high, then humidity is fairly high”
Lets define: T – universe of discourse for temperature H – universe of discourse for humidity t∈T, h∈H – variables for temperature and humudityDenote “high” as A, A⊆T Denote “fairly high” as B, B⊆H
Then the rule becomes: R(t,h): if t is A then h is B or R(t,h): R(t) → R(h)
Fuzzy rule: “If temperature is high, then humidity is fairly high”
Lets define: T – universe of discourse for temperature H – universe of discourse for humidity t∈T, h∈H – variables for temperature and humudityDenote “high” as A, A⊆T Denote “fairly high” as B, B⊆H
Then the rule becomes: R(t,h): if t is A then h is B or R(t,h): R(t) → R(h)
http://if.kaist.ac.kr/lecture/cs670/textbook/
EXAMPLE OF FUZZY EXAMPLE OF FUZZY IMPLICATIONIMPLICATION
if we know A and B, we can find R(t,h)=A×B
RC(t, h) = A × B = ∫µA(t) ∧ µB(h) / (t, h)
Mamdani (min) implication
if we know A and B, we can find R(t,h)=A×B
RRCC(t(t, h) = A , h) = A ×× B B = = ∫∫µµAA(t(t) ) ∧∧ µµBB(h(h) / (t, h) ) / (t, h)
MamdaniMamdani (min) (min) implication implication
http://if.kaist.ac.kr/lecture/cs670/textbook/
t t 20 20 30 30 40 40
µA(t) µA(t) 0.1 0.1 0.5 0.5 0.9 0.9
h h 20 20 50 50 70 70 90 90
µB(h) µB(h) 0.2 0.2 0.6 0.6 0.7 0.7 1 1
20 20 50 50 70 70 90 90
20 20 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
30 30 0.2 0.2 0.5 0.5 0.5 0.5 0.5 0.5
40 40 0.2 0.2 0.6 0.6 0.7 0.7 0.9 0.9
tthh
EXAMPLE OF FUZZY EXAMPLE OF FUZZY IMPLICATIONIMPLICATION
we know RC(t, h) for fuzzy rule “If temperature is high, then humidity is fairly high”
According to this rule, what is the humidity when “temperature is fairly high” or t is A’, A’⊆T ?
dgtgz
we know RRCC(t(t, h), h) for fuzzy rule for fuzzy rule “If temperature is high, then humidity is fairly high”
According to this rule, what is the humidity when “temperature is fairly high” or t is A’, A’⊆T ?
dgtgzhttp://if.kaist.ac.kr/lecture/cs670/textbook/
t 20 30 40
µA′(t) 0.01 0.25 0.81
EXAMPLE OF FUZZY EXAMPLE OF FUZZY IMPLICATIONIMPLICATION
We can use composition of fuzzy relations to find R(h)!
R(t)
RC(t, h)
R(h) = R(t) ο RC(t, h)
We can use composition of fuzzy relations to find R(h)!
R(t)
RRCC(t(t, h), h)
R(hR(h) = ) = R(tR(t) ) οο RRCC(t(t, h), h)
http://if.kaist.ac.kr/lecture/cs670/textbook/
t 20 30 40 µA′(t) 0.01 0.25 0.81
20 20 50 50 70 70 90 90
20 20 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
30 30 0.2 0.2 0.5 0.5 0.5 0.5 0.5 0.5
40 40 0.2 0.2 0.6 0.6 0.7 0.7 0.9 0.9
tthh
h h 20 20 50 50 70 70 90 90
µB′(h)µB′(h) 0.2 0.2 0.6 0.6 0.7 0.7 0.81 0.81
COMPOSITIONAL RULE OF COMPOSITIONAL RULE OF INFERENCEINFERENCE
In order to draw conclusions from a set of rules (rule base) oneneeds a mechanism that can produce an output from a collection of rules. This is done using the compositional rule of inference.
Consider a single fuzzy rule and its inference Rule: if v is A then w is C Input: v is A′Result: C′A ⊂ U, C ⊂ W, v ∈ U, and w ∈ C.
The fuzzy rule is interpreted as an implication R:A→C or R=A×C
When input A′ is given to the inference system, the output C′ = A′ ο R
In order to draw conclusions from a set of rules (rule base) oneneeds a mechanism that can produce an output from a collection of rules. This is done using the compositional rule of inference.
Consider a single fuzzy rule and its inference Rule: if v is A then w is C Input: v is A′Result: C′A ⊂ U, C ⊂ W, v ∈ U, and w ∈ C.
The fuzzy rule is interpreted as an implication R:A→C or R=A×C
When input A′ is given to the inference system, the output C′ = A′ ο R
http://if.kaist.ac.kr/lecture/cs670/textbook/
COMPOSITIONAL RULE OF COMPOSITIONAL RULE OF INFERENCEINFERENCE
C′ = A′ ο R “ο“ is the composition operator. The inference
procedure is called “compositional rule of inference”.The inference mechanism is determined by two factors:
1. Implication operators: Mamdani: min Larsen: algebraic product
2. Composition operators: Mamdani: max-min Larsen: max-product
C′ = A′ ο R “ο“ is the composition operator. The inference
procedure is called “compositional rule of inference”.The inference mechanism is determined by two factors:
1. Implication operators: Mamdani: min Larsen: algebraic product
2. Composition operators: Mamdani: max-min Larsen: max-product
http://if.kaist.ac.kr/lecture/cs670/textbook/
COMPOSITIONAL RULE OF COMPOSITIONAL RULE OF INFERENCEINFERENCE
Compositional rule of inference can be represented graphically as a combination of cylindrical extension, intersection and projection of fuzzy sets:
1. Build a cylindrical extension of A, A(x,y)2. Determine intersection of R(x,y) and A(x,y)3. Build projection of R(x,y)∧A(x,y)
Compositional rule of inference can be represented graphically as a combination of cylindrical extension, intersection and projection of fuzzy sets:
1. Build a cylindrical extension of A, A(x,y)2. Determine intersection of R(x,y) and A(x,y)3. Build projection of R(x,y)∧A(x,y)
COMPOSITIONAL RULE OF COMPOSITIONAL RULE OF INFERENCEINFERENCE
INFERENCE METHODSINFERENCE METHODS
There are many methods to perform fuzzy inference. Consider a fuzzy rule:
R1: if u is A1 and v is B1 then w is C1
Inputs u and v can be: crisp inputs. Crisp inputs can be treated as fuzzy singletons fuzzy sets A’ and B’
There are many methods to perform fuzzy inference. Consider a fuzzy rule:
R1: if u is A1 and v is B1 then w is C1
Inputs u and v can be: crisp inputs. Crisp inputs can be treated as fuzzy singletons fuzzy sets A’ and B’
http://if.kaist.ac.kr/lecture/cs670/textbook/
MAMDANI METHODMAMDANI METHODThis method uses the minimum operation RC as a
fuzzy implication and the max-min operator for the composition.
Suppose a rule base is given in the following form: Ri: if u is Ai and v is Bi then w is Ci, i = 1, 2, …, n
for u ∈ U, v ∈ V, and w ∈ W.Then, Ri = (Ai and Bi) → Ci is defined by
This method uses the minimum operation RC as a fuzzy implication and the max-min operator for the composition.
Suppose a rule base is given in the following form: Ri: if u is Ai and v is Bi then w is Ci, i = 1, 2, …, n
for u ∈ U, v ∈ V, and w ∈ W.Then, Ri = (Ai and Bi) → Ci is defined by
http://if.kaist.ac.kr/lecture/cs670/textbook/
),,()( wvuiiii CBandAR →= µµ ),,()( wvuiiii CBandAR →= µµ
MAMDANI METHODMAMDANI METHODCase 1: Inputs are crisp and treated as fuzzy singletons.
u = u0, v = v0
Inference if … then …Result
Example:
if temperature is high and humidity is high then fan speed is high
How to determine the fan speed for temperature 85ºF and humidity 93%?
Case 1: Inputs are crisp and treated as fuzzy singletons.uu = = uu00, , vv = = vv00
Inference if … then …Result
Example:
if temperature is high and humidity is high then fan speed is high
How to determine the fan speed for temperature 85ºF and humidity 93%?
http://if.kaist.ac.kr/lecture/cs670/textbook/
)()]()([)( 00 wvanduwiiii CBAC µµµµ →=′ )()]()([)( 00 wvanduwiiii CBAC µµµµ →=′
MAMDANI METHODMAMDANI METHOD
Mamdani method uses min operator (∧) as fuzzy implication function (→):
αi is called “firing strength”, “matching degree”, “satisfaction degree”
Mamdani method uses min operator (∧) as fuzzy implication function (→):
ααii is called is called ““firing strengthfiring strength””, , ““matching degreematching degree””, , ““satisfaction degreesatisfaction degree””
http://if.kaist.ac.kr/lecture/cs670/textbook/
0 00
1 1 1
u v wu0 v0
α1C1′
MIN Because of the “AND”connective
MIN of αi and Ci Because of the implication function
MAMDANI METHODMAMDANI METHODFor multiple rules (for example, two rules R1 and R2):For multiple rules (for example, two rules R1 and R2):
http://if.kaist.ac.kr/lecture/cs670/textbook/
0 0
0
0 0 0
01
1 1
1 1 1
1
u
u
v
v
w
wminu0 v0
α1
α2
C1′
C2′
C1′ C2′
MAMDANI METHODMAMDANI METHODIn general:
max min
In general:
max min
http://if.kaist.ac.kr/lecture/cs670/textbook/
0 0
0
0 0 0
0 1
1 1
1 1 1
1
u
u
v
v
w
wminu
0
v0
α1
α2
C1′
C2′
C1′ C2′
MAMDANI METHODMAMDANI METHOD
Case 2: Inputs are fuzzy sets A’, B’Case 2: Inputs are fuzzy sets AA’’, B, B’’
http://if.kaist.ac.kr/lecture/cs670/textbook/
))]()((max)),()((maxmin[
)()(
vvuuwhere
ww
ii
ii
BBvAAui
CiC
µµµµα
µαµ
∧∧=
∧=
′′
′
))]()((max)),()((maxmin[
)()(
vvuuwhere
ww
ii
ii
BBvAAui
CiC
µµµµα
µαµ
∧∧=
∧=
′′
′
0 00
1 1 1
u v w
α1
A1 A′ B′ B1 C1
MAMDANI METHODMAMDANI METHOD
For multiple rules, For multiple rules,
http://if.kaist.ac.kr/lecture/cs670/textbook/
0 0
0
0 0 0
01
1 1
1 1 1
1
u
u
v
v
w
wmin
α1
α2
A1 A′ B′
A′ B′
B1 C1
A2 B2 C2
EXAMPLE OF MAMDANI EXAMPLE OF MAMDANI METHODMETHOD
Let the fuzzy rule base consist of one rule:R: If u is A then v is B
where A=(0, 2, 4) and B=(3, 4, 5) are triangular fuzzy sets
Question 1: What is the output B’ if the input is a crisp value u0=3?
Question 2: What is the output B’ if the input is a fuzzy set A′=(0, 1, 2)?
Let the fuzzy rule base consist of one rule:R: If R: If uu is A then is A then vv is B is B
where where A=(0, 2, 4)A=(0, 2, 4) and and B=(3, 4, 5)B=(3, 4, 5) are are triangular fuzzy setstriangular fuzzy sets
Question 1: What is the output Question 1: What is the output BB’’ if the input is a if the input is a crisp value crisp value uu00=3=3??
Question 2: What is the output Question 2: What is the output BB’’ if the input is a if the input is a fuzzy set fuzzy set AA′=(0, 1, 2)?
http://if.kaist.ac.kr/lecture/cs670/textbook/
EXAMPLE OF MAMDANI EXAMPLE OF MAMDANI METHODMETHOD
http://if.kaist.ac.kr/lecture/cs670/textbook/
0 2 3 4
u0
1
1
0.5
B
B′
3 4 5
A
0 2 3 4
1
1
0.5
B
B′
3 4 5
AA’
Fuzzy inference with input u0=3 Fuzzy inference with input A′=(0, 1, 2).
LARSEN METHODLARSEN METHOD
This method uses the product operation RP as a fuzzy implication and the max-product operator for the composition.
Suppose a rule base is given in the following form: Ri: if u is Ai and v is Bi then w is Ci, i = 1, 2, …, n
for u ∈ U, v ∈ V, and w ∈ W. Then, Ri = (Ai and Bi) → Ci is defined by
This method uses the product operation RP as a fuzzy implication and the max-product operator for the composition.
Suppose a rule base is given in the following form: Ri: if u is Ai and v is Bi then w is Ci, i = 1, 2, …, n
for u ∈ U, v ∈ V, and w ∈ W. Then, Ri = (Ai and Bi) → Ci is defined by
http://if.kaist.ac.kr/lecture/cs670/textbook/
),,()( wvuiiii CBandAR →= µµ ),,()( wvuiiii CBandAR →= µµ
LARSEN METHODLARSEN METHODCase 1: Inputs are crisp and treated as fuzzy singletons.
u = u0, v = v0
` Inference if … then …result
For multiple rules:
Case 1: Inputs are crisp and treated as fuzzy singletons.uu = = uu00, , vv = = vv00
` ` Inference if … then …result
For multiple rules:
)()()(
)()]()([
)()]()([)(
00
00
00
vuwherew
wvu
wvanduw
iii
iii
iiii
BAiCi
CBA
CBAC
µµαµα
µµµ
µµµµ
∧==
∧=
→=
•
•
′
)()()(
)()]()([
)()]()([)(
00
00
00
vuwherew
wvu
wvanduw
iii
iii
iiii
BAiCi
CBA
CBAC
µµαµα
µµµ
µµµµ
∧==
∧=
→=
•
•
′
http://if.kaist.ac.kr/lecture/cs670/textbook/
i
n
i
C
n
iCi
n
iC
CUC
wwwii
′=′
==
=
′=
•=
′
1
11)(V)]([V)( µµαµ
i
n
i
C
n
iCi
n
iC
CUC
wwwii
′=′
==
=
′=
•=
′
1
11)(V)]([V)( µµαµ
LARSEN METHODLARSEN METHOD
http://if.kaist.ac.kr/lecture/cs670/textbook/
1 1 1
1 1 1
1
0 0 0
0
000
u v w
u v w
min
w
α1
α2
Graphical representation of Larsen method with singleton input
LARSEN METHODLARSEN METHOD
Case 2: Inputs are fuzzy sets A’, B’
For multiple rules:
Case 2: Inputs are fuzzy sets A’, B’
For multiple rules:
))()((max)),()((maxmin[
)()(
vvuuwhere
ww
ii
ii
BBvAAui
CiC
µµµµα
µαµ
∧∧=
=
′′
•′
))()((max)),()((maxmin[
)()(
vvuuwhere
ww
ii
ii
BBvAAui
CiC
µµµµα
µαµ
∧∧=
=
′′
•′
http://if.kaist.ac.kr/lecture/cs670/textbook/
i
n
i
C
n
iCi
n
iC
CUC
wwwii
′=′
==
=
′=
•=
′
1
11)(V)]([V)( µµαµ
i
n
i
C
n
iCi
n
iC
CUC
wwwii
′=′
==
=
′=
•=
′
1
11)(V)]([V)( µµαµ
LARSEN METHODLARSEN METHOD
Graphical representation of Larsen method with fuzzy set inputs
0 0
0
0 0 0
01
1 1
1 1 1
1
u
u
v
v
w
wmin
α1
α2
EXAMPLE OF LARSEN METHODEXAMPLE OF LARSEN METHOD
the fuzzy rule base consist of one rule:R: If u is A and v is B then w is C
ere A=(0, 2, 4), B=(3, 4, 5) and C=(3,4,5)re triangular fuzzy sets
estion 1: What is the output C’ if the inputs are risp values u0=3, v0=4?
estion 2: What is the output C’ if the inputs are zzy sets A′=(0, 1, 2) and B’=(2,3,4)?
the fuzzy rule base consist of one rule:R: If R: If uu is A and is A and vv is B then is B then ww is C is C
ere ere A=(0, 2, 4),A=(0, 2, 4), B=(3, 4, 5)B=(3, 4, 5) and and C=(3,4,5)C=(3,4,5)re triangular fuzzy setsre triangular fuzzy sets
estion 1: What is the output estion 1: What is the output CC’’ if the inputs are if the inputs are risp values risp values uu00=3, v=3, v00=4=4??
estion 2: What is the output estion 2: What is the output CC’’ if the inputs are if the inputs are zzy sets zzy sets AA′=(0, 1, 2) and B’=(2,3,4)?
XAMPLE OF LARSEN METHODXAMPLE OF LARSEN METHOD
1
0.5
2 3 4
u0
A 1
5
v0
3 4
B
1
3 4
C
5
Larsen method with input u0 =3, v0=4
2 40
1 1
0.5
AA′
1
3 4
C
51
BB′
3 4 52
2/3
Larsen method with input A′=(0, 1, 2), B′=(2, 3, 4).
DEFUZZIFICATIONDEFUZZIFICATION
The output of Mamdani and Larsen nference methods is a fuzzy set!
For practical applications a crisp value is often needed
The process of converting a fuzzy answer nto a crisp value is called defuzzification
The output of Mamdani and Larsen nference methods is a fuzzy set!
For practical applications a crisp value is often needed
The process of converting a fuzzy answer nto a crisp value is called defuzzification
SUMMARYSUMMARY
nference - the logical process by which new facts are derived from known facts by he application of inference rules.
Fuzzy rules – a convenient way to epresent knowledge
A fuzzy rule can be represented as a fuzzy elation connected by a fuzzy implication unction The fuzzy inference procedure is called thecompositional rules of inference
nference - the logical process by which new facts are derived from known facts by he application of inference rules.
Fuzzy rules – a convenient way to epresent knowledge
A fuzzy rule can be represented as a fuzzy elation connected by a fuzzy implication unction The fuzzy inference procedure is called thecompositional rules of inference
SUMMARYSUMMARY
Mamdani and Larsen methods are two very popular methods of fuzzy inference. There are many more inference methodsDefuzzification is needed for the results obtained through fuzzy inference.
Mamdani and Larsen methods are two very popular methods of fuzzy inference. There are many more inference methodsDefuzzification is needed for the results obtained through fuzzy inference.