You are on page 1of 17

THE ULTIMATE BEGINNERS GUIDE TO FUZZY LOGIC

COURSE CONTENT

• Part 1 – basic intuition


• Linguistic variables, antecedents, consequent, membership
functions, fuzzification, math for defuzzification
• Part 2 – implementation with skfuzzy library
• Tipping problem
• Vacuum cleaner problem
• Part 3 – clustering with fuzzy c-means
• Credit card clients

• Suitable for beginners


FUZZY LOGIC – BASIC INTUITION

• Applications
• First understanding
• Linguistic variables and membership (pertinence)
• Steps for fuzzy inference
• Mathematical calculations
FUZZY LOGIC – APPLICATIONS
FUZZY LOGIC

• If cost LOW and benefit HIGH then cost-benefit HIGH


• If cost HIGH and benefit HIGH then cost-benefit MEDIUM
• If cost LOW and benefit LOW then cost-benefit MEDIUM
• If cost HIGH and benefit LOW then cost-benefit LOW

• High cost and high benefit can be “half true” or “half false”
• If cost-high < 0.2 and benefit-high > 0.8 then cost-benefit HIGH
• Cost high = a little bit false
• Benefit high = truer
FUZZY LOGIC

• Boolean logic: full glass or empty glass


• Empty, half empty, half full, full

Fonte: http://www.yaldex.com/games-programming/0672323699_ch12lev1sec11.html
FUZZY LOGIC

• Jan Lukasiewicz (1878 – 1956)


• Lofti Asker Zadeh is considered to be the first author of article on fuzzy logic – 60’s
• Original paper: Fuzzy Sets published on Journal Information and Control
• It is not possible to answer only “yes” or “no”, but “maybe” or “almost”
• Values in the range from 0 to 1: 0.9 (almost true) e 0.1 (almost false)

Middle age
Middle age

Age Age
FUZZY LOGIC

• Linguistic variables (names for the fuzzy sets)


• Membership functions (pertinence functions)
• Temperature until 30: membership degree = 1 considering “Freezing”
• The membership degree in the “Freezing” group decreases as the temperature increases
• Temperature equal to 50 belongs “fully” to the “Cool” group
• Temperature above 90: membership degree = 1 considering “Hot”
FUZZY LOGIC – COMPONENTS

• Input variables (antecedents)


• Food quality (bad, decent or great)
• Service quality (bad, decent or great)
• Output variable (consequent)
• Tip (low, medium or high)
• Rules
• If the service is great and food is also great then the tip will be high
• To get the result (or the prediction), the defuzzification
calculation is executed
FUZZY LOGIC – COMPONENTS

Source: https://www.researchgate.net/figure/Components-of-a-fuzzy-logic-controller_fig2_264416989
CENTROID DEFUZZIFICATION

Calculation of “X” central of the areas: 6.49


- Centroid in X freezing: 3.5 freezing
cool
- Centroid in X cool: 8.5
Trapeze calculation: find the smallest and largest base on X,
considering the membership degree in Y
Smallest base (6.5)
Area calculation:
Membership degree * (smaller base + larger base)/2
Area “freezing”: 0.4 * (6.5 + 7) / 2 = 2.7
Area “cool”: 0.6 * (6.5 + 7) / 2 = 4.05
Larger base (7.0)
temperature
Weighted average calculation
(X “freezing” * area freezing + X “cool” * area cool) / (area X “freezing” X “cool”
freezing + area cool)
Weighted average: (3.5*(2.7) + 8.5*(4.05)) / (2.7 + 4.05) = 6.49
BISECTOR DEFUZZIFICATION

Calculation of “X” central of the areas: 6.50


- Centroid in X freezing: 3.5 freezing
cool
- Centroid in X cool: 8.5

Weighted average calculation (bissector):


(X “freezing” * Y “freezing”) + (X “cool” * Y “cool”) / X
“freezing” + Y “cool”

Weighted average: (3.5 * 0.4) + (8.5 * 0.6) / 0.4 + 0.6 =


6.5
temperature

X “freezing” X “cool”
MOM DEFUZZIFICATION – MEAN OF MAXIMUM

It is the value in the middle of X axis

MOM = 9
freezing
cool

temperature
SOM DEFUZZIFICATION – SMALLEST OF THE
MAXIMUM
It is the smallest value of the X axis

SOM = 6
freezing
cool

temperature
LOM DEFUZZIFICATION – LARGEST OF MAXIMUM

It is the highest value of the X axis

LOM = 12
freezing
cool

12

temperature
FUZZY SYSTEMS – IMPLEMENTATION

• skfuzzy library
• Tipping problem
• Vaccum cleaner problem
• Easy way and hard way
• More defuzzification functions
CLUSTERING WITH FUZZY C-MEANS

• Clustering – intuition
• Preprocessing the dataset
• Choosing the number of clusters
• Interpreting the results

You might also like