Fuzzy Sets and Fuzzification: Prof. Dr. Allaeldin H. Kassam

Download as pdf or txt
Download as pdf or txt
You are on page 1of 95

Fuzzy Sets and

Fuzzification

Prof. Dr. AllaEldin H. Kassam


Crisp Sets
• Everything is either true or false
• No uncertainty is allowed
• An item either is
o entirely within a set, or
o entirely not in a set
• The Law of the Excluded Middle
o X must be either in set A or in set not-A
o no middle ground is allowed
Crisp Sets
• Opposite sets (A and not-A) must between
them contain everything
• Venn diagrams
Fuzzy Sets
• Items can belong to a fuzzy set to different
degrees
o degrees of membership
• Completely within a set is a membership
degree of 1
• Completely outside a set is a membership
degree of 0
Fuzzy Sets
• Degrees of membership must sum to 1
• An item can be both A and not-A to different
degrees
o e.g. A to a degree of 0.8, not-A 0.2
• Degrees of membership are expressed with
membership functions
• Range of values a variable can take is called
the universe of discourse
Membership Functions
• A membership function describes the degree
of membership of a value in a fuzzy set
• Referred to as MF
o Also

 where x is the value being fuzzified

• There are many different types of MF


• Which one to use depends on the problem
Singleton MF
Rectangular MF
Triangular MF
• A family of MF
• Constantly tend towards zero and one
• Three in the family
o Left-shouldered
o Triangular
o Right-shouldered
Triangular MF
The membership function is a graphical representation of the magnitude of participation of
each input. It associates a weighting with each of the inputs that are processed, define
functional overlap between inputs, and ultimately determines an output response. The rules use
the input membership values as weighting factors to
determine their influence on the fuzzy output sets of the final output conclusion. Once the
functions are inferred, scaled, and combined, they are defuzzified into a crisp output which
drives the system. There are different membership functions associated with each input and
output response. Some features to note are:
SHAPE - triangular is common, but bell, trapezoidal, haversine and, exponential have been
used. More complex functions are possible but require greater computing overhead to
implement.. HEIGHT or magnitude (usually normalized to 1) WIDTH (of the base of
function), SHOULDERING (locks height at maximum if an outer function. Shouldered
functions evaluate as 1.0 past their center) CENTER points (center of the member function
shape) OVERLAP (N&Z, Z&P, typically about 50% of width but can be less).
Triangular MF
Gaussian MF
• A family of MF
• Smoothly tend towards one and zero
• Three in the family
o Z
o Gauss
o S
Gaussian MF

• c is the centre of the MF


• sigma is the width of the MF
• exp is the exponential function
Gaussian MF
• S function
Gaussian MF
• L is the left hand ‘breakpoint’ of the MF
• r is the right hand ‘breakpoint’ of the MF
• c is the centre of the MF

• Z function is symmetrical to S function


Membership Functions
• MF can also be represented by a set of
ordered pairs
• Pairs are crisp-fuzzy values
o A={(0,1.0),(1,1.0),(2,0.75),(3,0.5),(4,0.25),(5,0.0),(
6,0.0),(7,0.0),(8,0.0),(9,0.0),(10,0.0)}
o B={(0,0.0),(1,0.2),(2,0.4),(3,0.6),(4,0.8),(5,1.0),(6,0
.8),(7,0.6),(8,0.4),(9,0.2),(10,0.0)}
o C={(0,0.0),(1,0.0),(2,0.0),(3,0.0),(4,0.0),(5,0.0)(6,0.
25),(7,0.5),(8,0.75),(9,1.0),(10,1.0)}
Membership Functions
Fuzzification
• The process of determining the degree to
which a value belongs in a fuzzy set
• The value returned by a fuzzy MF
• Most variables in a fuzzy system have
multiple MF attached to them
• Fuzzifying that variable involves passing the
crisp value through each MF attached to that
value
Fuzzy Logic
• Same operations and function as in crisp
logic
• Must deal with degrees of truth rather than
absolute truths
• Fuzzy logic is a superset of crisp (Boolean)
logic
• AND, OR, NOT
• Crisp logical functions
o AND true is both parameters are true
o OR true if either parameter is true
o NOT reverses truth of argument
Fuzzy Logic
• AND function - crisp version (Left)
• AND function - fuzzy version (Right)
o take the minimum of the two arguments
Fuzzy Logic
• OR function - crisp version (Left)
• OR function - fuzzy version (Right)
o take the maximum of the two arguments
Fuzzy Logic
• NOT function - crisp version

• NOT function - fuzzy version


o subtract the truth value from one
Fuzzy Logic
• Output of fuzzy logical functions are the same
as crisp functions
o just calculated differently
o handle degrees of truth, rather than absolute
truths
• The basis of fuzzy rule based systems
Summary
• Fuzzy logic deals with uncertainty
• Allows degrees of truth
• Allows partial membership in sets
• Fuzzy membership functions describe degrees of
membership in fuzzy sets
• Many different types of MF exist
• Fuzzification = determining degree of membership
o uses fuzzy MF to do so
• Fuzzy logic extends Boolean operators to handle
partial truths
o the basis of fuzzy rules
Fuzzy Inference and
Defuzzification
Crisp Rules
• Consist of antecedents and consequents
• Each part of an antecedent is a logical expression
o e.g. A > 0.5, light is on
• Consequent will be asserted if antecedent is true
o IF (Presentation is Dull) AND (Voice is Monotone)
o THEN Lecture is boring
• Only one rule at a time allowed to fire
• A rule will either fire or not fire
• Have problems with uncertainty
• Have problems with representing concepts like
small, large, thin, wide
• Sequential firing of rules also a problem
o order of firing
Fuzzy Sets
• Supersets of crisp sets
• Items can belong to varying degrees
o degrees of membership
o [0,1]
• Fuzzy sets defined two ways
o membership functions
 MF
• sets of ordered pairs Membership functions (MF)
• Mathematical functions
• Return the degree of membership in a fuzzy set
• Many different types in existence
o Gaussian
o Triangular
Fuzzy Sets
• Can also be described as sets of ordered
pairs
• Pair Crisp,Fuzzy values
o A={(0,1.0),(1,1.0),(2,0.75),(3,0.5),(4,0.25),(5,0.0),(
6,0.0),(7,0.0),(8,0.0),(9,0.0),(10,0.0)}
• With enough pairs, can approximate any MF
• Fuzzification
• Process of finding the degree of membership
of a value in a fuzzy set
• Can be done by
o MF
o Interpolating set of pairs
Fuzzy Rules
• Also have antecedents and consequents
• Both deal with partial truths
• Antecedents match fuzzy sets
• Consequents assign fuzzy sets
• Fuzzy rules can have weightings
o [0,1]
o importance of rule
o commonly set to 1
Fuzzy Rules
• Restaurant tipping example
• Antecedent variables are
o quality of service
o quality of food
• Consequent variables are
o Tip
Fuzzy Rules
• Service can be
o Poor
o good
o excellent
• Universe of
discourse is 0-
10
Fuzzy Rules
• Food can be
o rancid
o good
o delicious
• Universe of
discourse is 0-10
Fuzzy Rules
• Tip can be
o cheap
o average
o generous
• Universe of
discourse is 0-
25
o % tip
Fuzzy Rules
• Rules for the tipping system
o IF service is poor or food is rancid
o THEN tip is cheap
o IF service is good
o THEN tip is average
o IF service is excellent or food is delicious
o THEN tip is generous
Fuzzy Inference
• Infers fuzzy conclusions from fuzzy facts
• Matches facts against fuzzy antecedents
• Assigns fuzzy sets to outputs
• Three step process
o fuzzify the inputs (fuzzification)
o apply fuzzy logical operators across antecedents
o apply implication method
Fuzzy Inference
• Implication is really two different processes
o inference
o composition
• Inference is the matching of facts to
antecedents
• Results in the truth value of each rule
o degree of support
o Alpha
• Assigns fuzzy sets to each output variable
• Fuzzy sets assigned to different degrees
• Determined by degree of support for rule
• Methods for assigning (inferring) sets
o min
o Product
Fuzzy Inference
• Product inferencing
• Multiply output MF by degree of support
Fuzzy Inference
• Min inference
• Cut output MF at degree of support

Where:
• is the output MF
• is the inferred MF
• v is the value being fuzzified
• z is the degree of support
Tipping Example
• Assume
o service is poor
 score of 2
o food is delicious
 score of 8
• How do we perform fuzzy inference with
these values?
Tipping Example
• Firstly, fuzzify the input values
• Service fuzzifies to
o Poor 0.8
o Good 0.2
o Excellent 0.0
• Food fuzzifies to
o Rancid 0.0
o Good 0.4
o Delicious 0.6
Tipping Example
• Now, calculate the degree of support for each
rule
• Rule 1:
o IF service is poor or food is rancid
o poor = 0.8
o rancid = 0.0
o max(0.8, 0.0) = 0.8
o Degree of support = 0.8
• Rule 2
o IF service is good
o good = 0.2
o max(0.2) = 0.2
o Degree of support = 0.2
Tipping Example
• Rule 3
o IF service is excellent or food is delicious
o excellent = 0.0
o delicious = 0.6
o max(0.0, 0.6) = 0.6
o Degree of support = 0.6

• Apply implication method


• Builds an inferred fuzzy set
• Find the min value for each output MF
• Cut output MF at this value
Min Inference
• Cut at 0.8
Min Inference
Min Inference
• Corresponding fuzzy set
o MF =
{(0,0),(1,0.2),(2,0.4),(3,0.6),(4,0.8),(5,0.8),(6,0.8),(
7,0.6),(8,0.4),(9,0.2),(10,0), (25,0)}
Min Inference
• Degree of support of 0.4
Min Inference
Min Inference
• Corresponding set
o MF =
{(0,0),(1,0.2),(2,0.4),(3,0.4),(4,0.4),(5,0.4),(6,0.4),(
7,0.4),(8,0.4),(9,0.2),(10,0), (25,0)}

Fuzzy Inference
• How are things different if we use product
inferencing?
Product Inference
Product Inference
• Corresponding set
o MF =
{(0,0),(1,0.16),(2,0.32),(3,0.48),(4,0.64),(5,0.8),(6,
0.64),(7,0.48),(8,0.16),(9,0.16),(10,0), (25,0)}
Product Inference
• Degree of support of 0.4
Product Inference
• Corresponding set
o MF =
{(0,0),(1,0.08),(2,0.16),(3,0.24),(4,0.32),(5,0.4),(6,
0.32),(7,0.24),(8,0.16),(9,0.08),(10,0), (25,0)}
Fuzzy Composition
• Aggregates the inferred MF into one
• Two methods of doing this
o Max
o Sum
• MAX takes the max fuzzy value for each value
of v
o equivalent to taking the fuzzy values for the highest
activated rule for each output fuzzy set
• SUM sums all fuzzy values for each value of v
o can lead to truth values > 1
o may need to be normalised to [0,1]
 implications for defuzzification
Fuzzy Composition
• Assume
o 3 MF attached to the output
 A, B and C
o Each MF has been asserted by two different rules
 6 rules activated (degrees of support) > 0
o Degrees of support
 0.8, 0.4, 0.6, 0.5, 0.7, 0.3
o Prod inference used
Fuzzy Composition
• For Set A

• For Set B

• For Set C
Max Composition
• MAX composition
o Take the max of each column
Max Composition
Sum Composition
• Sum composition
o sum each column
Sum Composition
Defuzzification
• Converts inferred MF into crisp numbers
• Many different types in existence
• Two common ones
o Centre of Gravity
o Mean of Maxima
COG Defuzzification
• Centre of Gravity
o CoG

• Where:
o y is the crisp value
o K is the number of items in the fuzzy set
COG Defuzzification
• Applying this to the first composite set
COG Defuzzification
COG Defuzzification
Defuzzification
• Mean of Maxima
o MoM
• Finds the mean of the crisp values that
correspond to the maximum fuzzy values
• If there is one maximum fuzzy value, the
corresponding crisp value will be taken from
the fuzzy set
MoM Defuzzification
• Applying this to the first composite set
• Maximum fuzzy value is 0.8
• Corresponding crisp value is 4
• This is the value returned by MoM
MoM Defuzzification
• What about sets with > 1 maximum?
• Apply this to the third composite set
MoM Defuzzification
• Maximum fuzzy value if 0.8
• Corresponding crisp values are
o 4, 5 and 6
MoM Defuzzification
Fuzzy Systems
Fuzzy Systems
• Three major components
o Fuzzy membership functions
o Fuzzy rules
o Fuzzy inference engine

• Membership Functions
o numerous types available
 Gaussian, Triangular, Singleton, Trapezoidal
o each type has different parameters
 e.g. centre, spread
o parameters effect the output of the function
Fuzzy Systems
• Fuzzy Rules
o map fuzzy facts to fuzzy conclusions
o different antecedent operators
• AND, OR, NOT
o consequents
• Zadeh-Mamdani
• Takagi-Sugeno
Fuzzy Systems
• Fuzzy inference engine
o final result depends on
 inference
 composition
 Defuzzification

• Used in fuzzy expert systems


• Like other expert systems, but knowledge
base is a fuzzy logic system
Fuzzy Systems
Developing a Fuzzy System
• Steps
o identify the problem
o define the input and output variables
o define the membership functions
o define the fuzzy rules
o select the inference / composition methods
o select the defuzzification method
o validate the system
Developing a Fuzzy System
• Identify the problem
o most essential step of solving any problem
o if you don’t know what the problem is, how can
you solve it?
o is the problem clearly defined?
o what are the goals of the system?

• Identify the problem


o is the problem suited to a fuzzy system?
o will one fuzzy system do, or are several needed?
• modular approach
• easier to optimise
Developing a Fuzzy System
• Define the input and output variables
o are all available input variables needed?
o are all available output variables needed?
o data analysis
o ranges of the variables
• universe of discourse
o variation of the variables
• implications for MF design
• Define the membership functions
o what type to use?
 Gaussian smoothly tends towards zero
 Triangular has a more constant slope
 Singelton useful for binary values
 Rectangular good for clear, non-overlapping groups
 Trapezoidal combines triangular and rectangular
Developing a Fuzzy System
• Define the membership functions
o what parameters?
o spread of each MF
o distribution of the MF
o labels attached to each MF
 Meaningful
• Define the fuzzy rules
o main problem in developing fuzzy systems
o how to get them?
 expert
 extract from data
 clustering
 extract from learning algorithm
 ANN
 EA
Developing a Fuzzy System
• Rules from experts
o does the developer understand the problem?
 Can the developer define the rules themselves?
 Can the developer understand the expert well enough
to transcribe accurate rules?
o does the expert understand fuzzy logic?
 Can the expert define the rules directly?
 Can the expert verify the rules created by the
developer?
• Rules from data
o use a clustering method
o clusters of a class indicate regions to define with
rules
 a rule defines a region
Rules from Clusters
Developing a Fuzzy System
• Rules from learning systems
o Artificial neural networks (ANN)
 train an artificial neural network
 analyse the connection weights
o devise fuzzy rules from those weights
o Evolutionary Algorithms (EA)
• use performance of system to drive evolution
• Completeness of the rules
o do the rules cover the entire input space?
o what happens if they don’t?
 is "no response" acceptable?
o contradictions in the rules?
o combine or split OR'd rules?
Developing a Fuzzy System
• Select the inference / composition methods
o different methods give very different results
o how to choose them?

• Select the defuzzification method


o many to choose from
o each gives different crisp results
o issues
 speed
 accuracy
Developing a Fuzzy System
• Validate the system
o involves
 gathering test data
 evaluating performance of system
 adjusting as necessary
o testing system in situ
 does the system give results the experts are happy
with?
 does it fail gracefully?
Developing a Fuzzy System
• Making adjustments
o improve performance
o correct errors
• Adding / deleting rules
o modularity of rules helps here
• Altering inference / composition /
defuzzification methods
• Modifying MF
o alter
 types
 parameters
• Adding / removing variables
o modularity of rules helps again here
Developing a Fuzzy System
• Adjustment gotchas
o a change in the MF may require a change in the
rules
o a change in the rules may require a change in the
MF
o a change in the inference process will effect
everything else
• optimisation is difficult
Advantages of Fuzzy Systems
• Universal function approximators
o given enough rules, a fuzzy system can
approximate any function to any degree of
precision
o number of rules required smaller than crisp rule
based function approximator
Advantages of Fuzzy Systems
• Comprehensibility
o well crafted fuzzy rules are easy to understand
 requires meaningful labels for MF
o makes a fuzzy expert system a "white box"
 See workings of the system
Advantages of Fuzzy Systems
• Modularity
o rules can be added and removed as needed
o eases development
 start with a small number of rules
o add as necessary to improve performance
o remove redundant rules to improve execution
speed
o optimise individual rules
Advantages of Fuzzy Systems
• Explainability
o execution trace
o which rules fired
o explains how system reached conclusion

• Uncertainty
o rules can fire even if all antecedents don't match
o can deal with inexact concepts
 smaller, faster etc.
o each rule corresponds to a wider range of input
values
Advantages of Fuzzy Systems
• Parallel execution of rules
o output calculated once at end of cycle
o rules are evaluated in parallel
o order does not matter
o no need for execution selection methods
• Compare to crisp rules
o order of rule execution can alter output of system
Disadvantages of Fuzzy Systems
• Computational cost
o more computations involved
 fuzzification
 fuzzy operators
 composition of output fuzzy set
 defuzzification
o complex MF can aggravate this problem
 simple triangular vs.. S or Pi functions
• Defining the rules
o where do the rules come from?
o major problem with rule-based systems
o need to get enough rules to be accurate
o rules need to be expressive
 comprehensibility
o rules need to be accurate
Disadvantages of Fuzzy Systems
• Optimisation
o a change in the MF can require a change in the
rules
o a change in the rules can require a change in the
MF
o each parameter / choice effects the others
o multi-parameter optimisation problem
• "Neural Network, Fuzzy Logic, and Genetic
Algorithms - Synthesis and Applications", by S.
Rajasekaran and G.A. Vijayalaksmi Pai, (2005),
Prentice Hall.
• "Soft Computing and Intelligent Systems Design
- Theory, Tools and Applications", by
Fakhreddine karray and Clarence de Silva
(2004), Addison Wesley.

You might also like