You are on page 1of 25

Fuzzy Systems

Overview:   Literature:
Why Fuzzy   chapter 4
Fuzzy Logic and Sets
Fuzzy Reasoning

DKS - Module 7
1

Why fuzzy thinking?

  Experts rely on common sense to solve problems


  Representation of vague, ambiguous terms
  If short means 300m or less, is 301m long?
  Fuzzy logic
  Not logic that is fuzzy
  But logic that describes fuzzyness = vagueness

2 16/12/08 DKS - Module 7

1
Vague concepts

-  at least 1.80 m?
-  could Frank be 1.78 m and be still tall?
-  if Frank is a basketball player
is 1.80m still tall?
-  if Frank is a kid of 10 years and 1.80 m
isn’t Frank very tall?

3 16/12/08 DKS - Module 7

Numerical vs. Logic uncertainty


reasoning

  Numerical systems: degree of belief

  Logical systems: degree of membership

4 16/12/08 DKS - Module 7

2
Fuzzy Logic - I

  Approach to formal treatment of uncertainty


  Relies on quantifying and reasoning through natural
language
  uses linguistic variables to describe concepts with vague
values
•  tall, large, small, heavy, ...
  Based on the idea that all things admit of degrees
•  Really hot, very tall, kind of small, light blue,…

5 16/12/08 DKS - Module 7

Fuzzy Logic - II

  Boolean logic uses sharp distinctions


  Fuzzy logic reflects how people think

  Fuzzy logic is a set of mathematical principles for


knowledge representation and reasoning based on degrees
of membership

6 16/12/08 DKS - Module 7

3
Fuzzy set
Crisp set (tall men):

  Is a function f: domain → [0,1]

Fuzzy set (tall men):

7 16/12/08 DKS - Module 7

Representing a domain
Fuzzy sets (men’s height):

8 16/12/08 DKS - Module 7

4
Membership function

  Categorization of element x into a set A


  described through a membership function µA(x)
  Formally, given a fuzzy set A of universe X
  µA(x): X → [0,1], where
•  µA(x) = 1 if x is totally in A µTall(200) = 1
•  µA(x) = 0 if x is totally not in A µTall(160) = 0
•  0 < µA(x) <1 if x is partially in A 0 < µTall(180) <1
  (Discrete) Fuzzy set A is represented as:
  A = {µA(x1)/x1, µA(x2)/x2, …, µA(xn)/xn}

  Tall = {0/160, 0.2/170, 0.8/180, 1/190}

9 16/12/08 DKS - Module 7

Operations on Fuzzy Sets

  Union: µA∪B(x) = max(µA(x), µB(x))


  Intersection: µA∩B(x) = min(µA(x), µB(x))
  Complement: µ ¬A(x) = 1 - µA(x)

10 16/12/08 DKS - Module 7

5
Fuzzy logic

  Based on fuzzy set properties


  Logic OR (∨) is set union
  A ∨ B = µA∪B(x) = max(µA(x), µB(x))
  Logical AND (∧) is set intersection
  A ∧ B = µA∩B(x) = min(µA(x), µB(x))
  Logical NOT (¬) is set complement
  ¬A = µ ¬A(x) = 1 - µA(x)

11 16/12/08 DKS - Module 7

Properties of fuzzy sets

  The same as for crisp sets


  Commutativity
  Associativity
  Distributivity
  Idempotency
  Identity
  De Morgan’s Laws
  …

12 16/12/08 DKS - Module 7

6
Linguistic variables

  A linguistic variable is a fuzzy variable


  The linguistic variable speed ranges between 0 and 300km/h
and includes the fuzzy sets slow, very slow, fast,…
  Fuzzy sets define the linguistic values
  Hedges are qualifiers of a linguistic variable
  All purpose: very, quite, extremely
  Probability: likely, unlikely
  Quantifiers: most, several, few
  Possibilities: almost impossible, quite possible

13 16/12/08 DKS - Module 7

Fuzzy set with hedge very

14 16/12/08 DKS - Module 7

7
Interpretation of hedges

  Hedges modify the shape of a fuzzy set

15 16/12/08 DKS - Module 7

Fuzzy rules

  A fuzzy rule is defined as a conditional statement of the


form
IF x is A
THEN y is B
  Where x and y are linguistic variables and A and B are
linguistic values determined by fuzzy sets on the universes
of discourse X and Y.

16 16/12/08 DKS - Module 7

8
Fuzzy rule example

IF height is tall
THEN weight is heavy.

  Where the fuzzy classes height and weight have a given


range (i.e. the universe of discourse).
  range(height) = [140, 220]
  range(weight) = [50, 250]

17 16/12/08 DKS - Module 7

Reasoning with fuzzy rules

  In classical systems, rules with true antecedents fire.


  In fuzzy systems, truth (i.e. membership in some class) is
relative – so all rules fire (to some extent).

18 16/12/08 DKS - Module 7

9
Applying fuzzy rules

  If the antecedent is true to some degree, the consequent is


true to the same degree.
  IF length is tall THEN weight is heavy

Tall men Heavy men

  µTall(x) = 0.7 → µHeavy(y) = 0.7

19 16/12/08 DKS - Module 7

Multiple antecedents

  IF x is A AND y is B THEN z is C
  IF x is A OR y is B THEN z is C
  Use unification (OR) or intersection (AND) operations to
calculate a membership value for the whole antecedent.
  AND: µC(z) = min(µA(x), µB(y))
  OR: µC(z) = max(µA(x), µB(y))

  E.g. If rain is heavy AND wind is strong THEN weather is bad


  ((µheavy(rain) = 0.7) ∧ (µstrong(wind) = 0.4)) → (µbad(weather) = 0.4)

20 16/12/08 DKS - Module 7

10
Multiple consequents

  IF x is A THEN y is B AND z is C

  Each consequent is affected equally by the membership in the


antecedent class(es).

  E.g. IF x is tall THEN x is heavy AND x has large feet


  µTall(x) = 0.7 → µHeavy(y) = 0.7 ∧ µLargeFeet(y) = 0.7

21 16/12/08 DKS - Module 7

Fuzzy Events

  Fuzzy probabilities:
  What is the probability of meeting a tall man?

  P(x is A) =

Where
  µA(x) is the membership function of elements in A
  P(x) is the probability of x
•  (Empirical evidence)

22 16/12/08 DKS - Module 7

11
Fuzzy probability

  What is the probability that temperature on July 16th is


around 25°C
  Based of average temperatures for July 16th:

°C 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

P .002 .005 .005 .01 .04 .11 .15 .21 .16 .14 .11 .04 .01 .005 .002

P(temp is around 25°C) =


1
= Σ µabout25(x)*P(x)
0 = µ (20)*P(20) + µ(21)*P(21) + … + µ(30)*P(30)
20 24 26 30
= 0*0.005 + 0.25*0.01 + 0.5*0.04 +… + 0*0.01
Around 25°C
= 0.8125
≈ 0,8

23 16/12/08 DKS - Module 7

Using hedges

  The probability that temperature on July 16th is around


25°C is likely
  P(temp is about 25°C) = 0.8

Likely with probability 0.95


Very likely with prob. 0.32

0.8

24 16/12/08 DKS - Module 7

12
Fuzzy Inference

  How to reason using Fuzzy Logic?


1.  Fuzzify input variables
2.  Evaluate rules
3.  Aggregate rule outputs
4.  Defuzzify the output

25 16/12/08 DKS - Module 7

Rule 1
w1
X is A1 y is B1
Rule 2 defuzzifier
X is A2 y is B2
w2
X Fuzzy
… aggregator y
Rule r
X is Ar y is Br
wr

26 16/12/08 DKS - Module 7

13
Step 1: Fuzzification

  Use crisp inputs from the user


  Determine membership values for all the relevant classes (i.e.
in right Universe of Discourse).

27 16/12/08 DKS - Module 7

Step 2: Rule evaluation

  Apply fuzzified inputs to all relevant rules


  Use union, intersection and complement operations to handle
composite antecedents
  Min-max method for composite antecedents produces clipped
functions

28 16/12/08 DKS - Module 7

14
Step 3: Result Aggregation

  Build membership function for each output (rule


consequents) by aggregating all the relevant classes
  Unification of outputs of all rules

29 16/12/08 DKS - Module 7

Step 4: Defuzzification (Mamdani)

  Definition: “It refers to the way a crisp value is extracted


from a fuzzy set as a representative value”

  There are five methods of defuzzifying a fuzzy set A of a


universe of discourse Z

  Centroid of area zCOA


  Bisector of area zBOA
  Mean of maximum zMOM
  Smallest of maximum zSOM
  Largest of maximum zLOM

30 16/12/08 DKS - Module 7

15
Step 4: Defuzzification (Mamdani)

  Use centre of area formula (centroid technique) to calculate crisp


output value
  Summation as approximation to integral value

31 16/12/08 DKS - Module 7

Step 4: Defuzzification

32 16/12/08 DKS - Module 7

16
Sugeno Fuzzy Models

  “If x is A & y is B then z = f(x, y)”


Where A & B are fuzzy sets in the antecedent, while z =
f(x, y) is a crisp function in the consequent

  If f(.,.) is a constant then it is a zero-order Sugeno


fuzzy model (special case of Mamdani model)

  Often: Weighted average of singletons in each fuzzy set

33 16/12/08 DKS - Module 7

Exercise

  Suppose 3 fuzzy rules that determine heart attack risk,


based on:
  Three universes of discourse (UoD):
•  Diet (1000-4000 cal/day): with fuzzy classes poor, good
•  Exercise (1000-4000 cal/day): with fuzzy classes high, low
•  Risk (0-100 likelihood): with fuzzy classes high, low, medium
  Represent membership functions graphically
  Show fuzzy inference for following sample data
•  What is the risk of heart disease of Mary who has a diet of 2500
cal/day and spends 1000 cal/day on exercise

34 16/12/08 DKS - Module 7

17
Rules

  Rule1: IF diet is poor AND exercise is low


THEN risk is high
  Rule2: IF diet is good AND exercise is high
THEN risk is low
  Rule3: IF diet is good OR exercise is high
THEN risk is medium

35 16/12/08 DKS - Module 7

Membership function: Diet

Mary?

36 16/12/08 DKS - Module 7

18
Membership function: Exercise

Mary?

37 16/12/08 DKS - Module 7

Membership function: Risk

Mary?

38 16/12/08 DKS - Module 7

19
Mamdani inference

1.  Fuzzify input variables


  Determine membership values
2.  Evaluate rules
  Based on membership values of (composite) antecedents
3.  Aggregate rule outputs
  Unify all membership values for output from all rules
4.  Defuzzify the output
  COG: Center of gravity (approx. by summation)

39 16/12/08 DKS - Module 7

Step 1: fuzzification

  Fuzzify values for Mary:


  has a diet of 2500 cal/day and spends 1000 cal/day on
exercise
  µpoordiet(2500) = 0,6

  µgooddiet(2500) = 0,8

  µhighexer(1000) = 0

  µlowexer(1000) = 1

40 16/12/08 DKS - Module 7

20
Step 2: rule evaluation

  Rule1:
  IF diet is poor (0,6) AND exercise is low (1) THEN risk
is high
  µA∧B(x) = min(µA(x), µB(x)) = 0,6
  Consequent is true to the same degree as the composition
of antecedent
  µriskhigh(Mary) = 0,6

41 16/12/08 DKS - Module 7

Membership: Risk High

42 16/12/08 DKS - Module 7

21
Step 2 (continuation)

  RULE1: IF diet is poor (0,6) AND exercise is low (1)


THEN risk is high (0,6)
  RULE2: IF diet is good (0,8) AND exercise is high (0)
THEN risk is low (0)
  RULE3: IF diet is good (0,8) OR exercise is high (0)
THEN risk is medium (0,8)

43 16/12/08 DKS - Module 7

Step 3: Aggregation

  Note that “low” has been clipped down to zero, and “average” hasn’t
been clipped, because the derived µ was higher than the original
membership function.
  The aggregate is simply the union of the three functions.

44 16/12/08 DKS - Module 7

22
Step 4: Defuzzification

  Centroid technique

  Example: sample every 12,5 units


  More points are better, integral is even better

  COG = 70

45 16/12/08 DKS - Module 7

Result

  The likelihood of heart disease for Mary is 70%

46 16/12/08 DKS - Module 7

23
Advantages of Fuzzy Logic

  general theory of uncertainty


  wide applicability, many practical applications
  natural use of vague and imprecise concepts
  helpful for commonsense reasoning, explanation

47 16/12/08 DKS - Module 7

Problems of Fuzzy Logic

  membership functions can be difficult to find


  multiple ways for combining evidence
  problems with long inference chains

48 16/12/08 DKS - Module 7

24
Coming up

  6 January 2008: Intelligent Interfaces (Agents and KS)


  13 January 2008: Knowledge Engineering (Evaluation)
  20 January 2008: KS in practice?

49 16/12/08 DKS - Module 7

25