AI Module5 Fuzzylogic Week10

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 54

Introduction to Fuzzy Logic

Contents
 Introduction to fuzzy logic
 Membership function
 Fuzzy sets
 Features of fuzzy sets
 Degree of membership
 Operations on fuzzy sets
 Fuzzy set identities
 Fuzzy logic architecture
 Fuzzy Inference system
 Fuzzy inference process steps

2
Introduction to Fuzzy logic

 It is a computational paradigm that is based on how humans


think.
 Dictionary meaning of ‘Fuzzy’ is vague/ indistinct.
 How can we represent expert knowledge that uses vague and
ambiguous terms in a computer?
 Fuzzy logic is not logic that is fuzzy, but logic that is used to
describe fuzziness. Fuzzy logic is the theory of fuzzy sets that
calibrate the vagueness.

2
Fuzzy logic

• Based on the idea that all things admit of degrees, i.e.


temperature, height, speed, distance, beauty – all come on a
sliding scale.

The motor is running really hot.


Tom is a very tall guy.

2
Temperature Example

Boolean vs.

• Fuzzy logic is a way to model logical reasoning where the


truth of a statement is not binary.
• A technique that facilitates the control of a complicated
system without knowledge of its mathematical
description.
Crisp Set vs Fuzzy Set

Cris Fuzzy
p Definitely
Fuzzy Logic Vs
Yes Boolean Logic
Are you under 40 Why not?
years of age? Are you young
No
………
Not that much

 Boolean logic can have only two possible values as 0/1, yes/no,
right/wrong etc.
 Fuzzy logic can be multi valued. It can have relative values like
yes, no, not so much, a little bit etc.
Crisp set vs Fuzzy set
• Crisp set:- A set is a collection of distinct elements, or members, without
repetition and without ordering.
E.g. atomic particles = {electron, proton, neutron}.

• Fuzzy set theory is a generalization of the classical set theory.


E.g. He is a rich man’, or ‘The car is very expensive’, or ‘Old people tend to be
weak’

A traditional crisp set A fuzzy set


7
Fuzziness/Vagueness/Inexactness
• Very young
• Very cheap
• Very expensive
• So cold
• Not so cold
• Not so hot
• Not so humid
• Not that old

• This vagueness is desirable because otherwise everyday conversation would have


been impossible.
• The classical set theory is not equipped to handle such vagueness as it does not
allow an element to be a partial member, or a partially non-member, of a set
simultaneously. Therefore, classical set theory is inadequate to model our intuitive
notion of a set in general.
8
Fuzziness/Vagueness/Inexactness
• Consider a family dataset

U = {Grand-pa, Grand-ma, Dad, Mom, Sister, Brother, Aunt} Crisp set


9
• The status of membership of an element x with respect to a given set S is expressed
with the help of a membership function m. A set, crisp or fuzzy, may be defined in
terms of membership function.
• Consider, set M of male family members and set F of female family members with
reference to the family.
• M (Dad) = 1, and M (Mom) = 0 Set Male
• F(Dad) = 0, and F(Mom) = 1 Set Female
Membership values of the other family members in M and F can be ascertained in similar
manner.
 It is convenient to express the membership of various elements with respect to a
fuzzy set with the help of a function, referred to as the membership function.
Example- fuzzy set A of senior persons on the universe of discourse U
The membership function of x in A
Membership function

where x represents the age of the concerned person.


The nature of the membership function for fuzzy set of senior family members
For example, as Grand-pa is more than 70 years old, he is a full member of A, mA
(Grand-pa) =1.0.
However, for Grand-ma we have mA (Grand-ma) = (63 – 30) / 40 = 33 / 40 =
0.825.
Hence Grand-ma is a senior person to a large extent, but not as fully as Grand-
pa.
Membership values of the senior family members
A = {(Grand-pa, 1.0), (Grand-ma, 0.825), (Dad, 0.275),(Mom, 0.2), (Aunty, 0.55)}

Fuzzy Sets
• Fuzzy set is a set having degrees of membership between 1 and 0.
• For example, Number of cars following traffic signals at a particular time out of all
cars present will have membership value between [0,1]
Compute the membership function
Features of Fuzzy Sets
• Normality
A fuzzy set F is said to be normal if there exists an element x that completely belongs
to F, F (x) = 1. A fuzzy set which is not normal is said to be sub-normal.
• Height
The height of a fuzzy set is defined as the maximal membership value attained by its
elements.

U is the universe of discourse, or, the reference set, for F, and height (F) is the height
of the fuzzy set F.
F is a normal fuzzy set if height (F) = 1.
• Support
The support of a fuzzy set F, denoted by supp (F), is the set of all elements
of the reference set U with non-zero membership to F.
Features of Fuzzy Sets
• Core
Th e core of a fuzzy set F is the set of all elements of the reference set U with complete
membership to F.

Both supp (F) and core (F) are crisp sets. It is easy to see that core (F) ⊆ supp (F).

• Cardinality
The sum of all membership values of the members of a fuzzy set F is said to be the
cardinality of F.
The fuzzy set M is normal, because we have M (d) = 1.0. Its height is 1.0. Moreover,
as we see, supp (M) = {a, c, d, e}, core (M) = {d}, and the cardinality of M is | M | =
0.375 + 0.5 +1.0 + 0.875 = 2.750.
Extent/ Degree of membership

 Example:
 Ann is 28, 0.8 in set “Young”
 Bob is 35, 0.1 in set “Young”
 Charlie is 23, 1.0 in set “Young”

 Unlike statistics and probabilities, the degree is not


describing probabilities that the item is in the set, but
instead describes to what extent the item is the set.

18
Membership function of fuzzy logic
A membership function
(MF) is a curve that
defines how each point in
Fuzzy values
DOM the input space is mapped
Degree of to a membership value (or
Membership degree of membership)
Young Middle Old
1 between 0 and 1. The input
space is often referred to
as the universe of
0.5
discourse.
0
25 40 55 Age

Fuzzy values have associated degrees of membership in the set.

19
Membership function?

Feature of Membership Function


FUZZY MEMBERSHIP FUNCTIONS

• Theoretically any function may act as the membership function


for a fuzzy set F.
• The nature of the membership function depends on the context
of the application.
• E.g. Hot for human body is cold for a blast furnace.
• Some popular membership functions are:
 Triangular
 Trapezoidal
 Gaussian
 S-function
Membership function
TRIANGULAR FUNCTION
TRAPEZOIDAL FUNCTION
GAUSSIAN FUNCTION

The advantage of Gaussian function is that it is differentiable everywhere.


S- FUNCTION

• S-function is differentiable everywhere.


• The step function can be approximated by the S-function as closely as required by
adjusting the parameters a and b.

The point m = (a + b) / 2 is known as the


crossover point of the S-function.
Operations on fuzzy sets

S.no. Operation/ Relation Description


1. Union () (x) = max {},

2. Intersection () (x) = min{},

3. Complementation (P’) (x) = 1-,

4. Equality (P = Q) Two fuzzy sets P and Q are equal if and only if ,


(x) =
5. Inclusion () P is included in Q, i.e., P is a subset of Q, written
as , if and only if , (x) <
6. Product (P.Q) (x) = X ,

7. Difference (P-Q) P-Q = P ’

8. Disjunctive sum (P) P = (P ’) ()


Fuzzy Set Identities
Let U = Flowers = {Jasmine, Rose, Lotus, Daffodil, Sunflower, Hibiscus, Chrysanthemum}} be
a universe on which two fuzzy sets, one of Beautiful flowers and the other one of Fragrant
flowers are defined as shown below.
Fuzzy Logic Architecture
Fuzzy Logic Architecture components
RULE BASE: It contains the set of rules and the IF-THEN
conditions provided by the experts to govern the decision-making
system, on the basis of linguistic information. Recent
Architecture
developments of theory
in fuzzy Fuzzy logic
offer several effective methods for
the design and tuning of fuzzy controllers. Most of these
developments reduce the number of fuzzy rules.

•FUZZIFICATION: It is used to convert inputs i.e. crisp numbers


into fuzzy sets. Crisp inputs are basically the exact inputs measured
by sensors and passed into the control system for processing, such
as temperature, pressure, rpm’s, etc.
Fuzzy Logic Architecture components
•INFERENCE ENGINE: It determines the matching degree of the
current fuzzy input with respect to each rule and decides which
rules are to be fired according to the input field. Next, the fired
Architecture
rules are combined toof Fuzzy
form logic
the control actions.

•DEFUZZIFICATION: It is used to convert the fuzzy sets obtained


by the inference engine into a crisp value. There are several
defuzzification methods available and the best-suited one is used
with a specific expert system to reduce the error.
Fuzzy Inference System (FIS)
• A fuzzy inference system is a form of artificial intelligence.
• Mimics the way humans approach solving a problem.
• It is a key unit of fuzzy logic system
•Fuzzy
Primary Interference System
work of FIS is Decision (FIS)
making

‘IF-THEN’ rules along with connectors such as ‘OR’ or ‘AND’


If p Then q
R: If ‘x is A’ Then ‘y is B’
R: A(x) B(y)
Methods of defining FIS
• Mamdani Fuzzy Inference System
• [A(x) B(y)]

• Zadeh’s Interpretation of fuzzy rule


• [A(x) B(y)]
Zadeh’s interpretation of fuzzy rules
Fuzzy inference process steps:

1. Fuzzification of the input variables


2. Application of fuzzy operators on the antecedent parts of the rules
3. Evaluation of the fuzzy rules
4. Aggregation of fuzzy sets across the rules
5. Defuzzification of the resultant fuzzy set
STRUCTURE OF A FUZZY INFERENCE SYSTEM.
FUZZIFICATION
The inputs to a fuzzy inference system are a number of crisp values corresponding to some
parameters. For each input, we have to determine the degree to which it belongs to the
appropriate fuzzy set through membership function. This is known as fuzzification, the
first step of the entire fuzzy inference process.

Fuzzification of the car’s


distance with respect to the
fuzzy set far away. Assuming
the distance to be 7 (in the
range 0–10) the fuzzy
membership is seen to be 0.5
here.
APPLICATION OF FUZZY OPERATORS ON THE
ANTECEDENT PARTS OF THE RULES
The antecedent of a fuzzy rule may consist of a single part or more than one parts joined
together with AND, or OR operators.
EVALUATION OF THE FUZZY RULES
Fuzzy rules are evaluated by employing some implication process. The input to the
implication process is the number provided by the antecedent and its output is a fuzzy set.
Th is output fuzzy set is obtained by reshaping the fuzzy set corresponding to the
consequent part of the rule with the help of the number given by the antecedent.
• The fuzzy set for the consequent of the rule R1, i.e., cross the road leisurely, has a triangular
membership profile as shown in the figure.
• As a result of applying fuzzy AND operator as the minimum of its operands, the antecedent
returns the value 0.5.
• The implication process reshapes the membership function of the fuzzy set leisurely by
taking the minimum between 0.5, and the membership value of leisurely at any point.
• The result is a trapezoidal membership function as depicted in the figure.
• As in the case of fuzzy logic operators there are several implication methods.
• Among these the min method proposed by Mamdani is followed here.
• It effectively truncates the fuzzy membership profile of the consequent with the value
returned by the antecedent.
AGGREGATION OF OUTPUT FUZZY SETS ACROSS THE RULES

• Decision-making through a fuzzy inference system has to take into account the
contribution of each rule in the system.
• Therefore the individual fuzzy sets obtained by evaluating the rules must be combined
in some manner into a single resultant fuzzy set.
• This aggregation process takes the truncated membership profiles returned by the
implication process as its input, and produces one fuzzy set for each output variable as
the output.
• Taking the maximum among all inputs (max), or taking the algebraic sum of all inputs
(sum) are two methods widely employed by the professionals.
• In the next figure, all three rules R1, R2, and R3 are placed together to show how the
outputs of all the rules are combined into a single fuzzy set using the max aggregation
method.
Two popular aggregation methods – max and sum.
DEFUZZIFICATION OF THE RESULTANT AGGREGATE
FUZZY SET
Defuzzification is the process of converting the aggregate output sets into one crisp value
for each output variable. This is the last step of a fuzzy inference process.
There are several defuzzification methods in vogue, viz., centroid method, centre-of-sums
(CoS) method, mean-of-maxima (MoM) method.
AGGREGATION OF FUZZY SETS ACROSS THE RULES.
Centroid method
Centre-of-gravity or centre-of-area method
Centroid method
Center of Sums (CoS) Method
The only difference is, here the aggregate output set is obtained by the sum method rather
than the max method.
Mean-of-Maxima (MoM) Method
MoM is a simple defuzzification method where the highest degree of membership among all
fuzzy sets is taken as the output defuzzified value. In case there are more than one elements,
say x1, …, xk, having the same highest degree of membership, then the mean of those points
is taken as the defuzzified value.
Mean-of-Maxima (MoM) Method
COMPUTATION OF AREAS AND CENTROIDS
Fuzzy inference process using centre of sums (CoS) method
Thank You

You might also like