Recap of Lecture 22 and Homework Check
LAST LECTURE · 5 MIN
Today: the fan has five rules and each gives a different opinion. How do we combine them into ONE fan speed?
Today's Plan (50 minutes)
ROADMAP
0-5
Recap of Lecture 22 and homework check
S02
5-8
Plan and learning outcomes
S03-S04
8-18
Module 1: The fuzzy inference process - five steps on the fan
S05-S08
18-27
Module 2: Mamdani - implication and defuzzification
S09-S11
27-35
Module 3: Sugeno - zero and first order; choosing a method
S12-S15
35-43
Class activity: inference by hand
S16
43-48
Common mistakes and recap quiz
S17-S18
48-50
Homework and next lecture
S19
Learning Outcomes (SLOs)
BY THE END OF THIS LECTURE YOU WILL BE ABLE TO
SLO 23.1
Explain the five steps of fuzzy inference: fuzzify, apply operators, implication, aggregation, defuzzify
→ CLO3 · C2 Understand
SLO 23.2
Apply Mamdani inference: firing strengths, clip or scale, max aggregation and defuzzification methods
→ CLO3 · C3 Apply
SLO 23.3
Apply zero- and first-order Sugeno inference and compare it with Mamdani
→ CLO3 · C3 Apply
- Course Learning Outcome(s) served
- CLO3: Apply various techniques and algorithms of AI used in general problem solving, optimization problems, constraint satisfaction problems, and game programming.
Slide 5
MODULE 1
The Fuzzy Inference Process
Five steps from crisp inputs to a crisp output
Five Steps of Fuzzy Inference
MODULE 1 · THE PROCESS
Fuzzify
Operators
Implication
Aggregate
Defuzzify
- Crisp input -> degrees.
- 30 °C: comfortable 0.33, hot 0.20
AND = min, OR = max, NOT = 1 - μ -> firing strength of each rule
Shape the THEN set by the strength (clip or scale)
Join all rule outputs into one fuzzy set (max)
One crisp number: centroid of the set
THE FAN RULE BASE (P08-P10)
- R1 IF temp is cold THEN fan is slow
- R2 IF temp is comfortable AND hum is dry THEN fan is slow
- R3 IF temp is comfortable AND hum is NOT dry THEN fan is medium
- R4 IF temp is hot AND hum is dry THEN fan is medium
- R5 IF temp is hot AND hum is NOT dry THEN fan is fast
Steps 1 and 2 on the Fan: 30 °C, 40 %
MODULE 1 · WORKED EXAMPLE
REAL OUTPUT: L23/STEPS.PY
- Step 1 Fuzzify the inputs
- temp 30 C is cold 0.00
- temp 30 C is comfortable 0.33
- temp 30 C is hot 0.20
- humidity 40 % is dry 0.33
- Step 2 Apply AND (min) / NOT (1 - mu) -> firing strengths
- R1 IF cold THEN slow 0.00
- R2 IF comfortable AND dry THEN slow 0.33
- R3 IF comfortable AND NOT dry THEN medium 0.33
- R4 IF hot AND dry THEN medium 0.20
- R5 IF hot AND NOT dry THEN fast 0.20
- Steps 3-5 Mamdani (clip, max, centroid) -> 45.04 %
- Sugeno (weighted average) -> 45.88 %
Firing strength: how strongly a rule applies, from 0 to 1. Several rules usually fire at the same time.
Ask: why is NOT dry = 0.67? Because 1 - 0.33 = 0.67 (complement from Lecture 22).
Steps 3 to 5: Clip, Aggregate, Defuzzify
MODULE 1 · THE INFERENCE DIAGRAM
- Read across a row: input degrees -> min -> clip the THEN set.
- R1 adds nothing: 30 °C is not cold (strength 0).
- Aggregate: max of the four amber shapes.
- Defuzzify: centroid = balance point = 45.04 %.
Centroid: z* = Σ μ(z)·z / Σ μ(z) over the output axis - the point where the shape would balance on a finger.
Slide 9
MODULE 2
Mamdani Inference
Ebrahim Mamdani, 1975 - fuzzy output sets
Implication: Clip or Scale?
MODULE 2 · STEP 3 CHOICES
REAL OUTPUT
- input clip scale
- 30 C, 40 % 45.04 44.51
- 36 C, 70 % 82.78 83.33
- 34 C, 65 % 81.43 83.33
Remember: both methods agree on the strongest opinion; they differ a little in how the shapes overlap.
Defuzzification Methods
MODULE 2 · STEP 5 CHOICES
REAL OUTPUT: L23/DEFUZZ_METHODS.PY
- method 30 C/40 % 36 C/70 %
- centroid 45.04 82.78
- bisector 43.66 84.64
- mom 33.00 95.00
- som 0.00 90.00
- lom 66.00 100.00
Why centroid? it uses the whole shape, so a small change in temperature gives a small change in fan speed. MOM can jump from 33 to 95.
Exam tip: for a flat top from 20 to 60: SOM = 20, LOM = 60, MOM = (20 + 60)/2 = 40.
Slide 12
MODULE 3
Sugeno Inference
Takagi-Sugeno-Kang, 1985 - crisp rule outputs
Sugeno: Zero-Order and First-Order
MODULE 3 · WEIGHTED AVERAGE
RULE OUTPUTS AND THE WEIGHTED AVERAGE
REAL OUTPUT: L23/SUGENO_ORDERS.PY
- zero-order: z = constant e.g. fast: z = 83
- first-order: z = p·t + q·h + r
- e.g. fast: z = 50 + 0.8·t + 0.1·h
- output z* = Σ wi·zi / Σ wi
- input zero-order first-order
- 30 C, 40 % 45.88 49.31
- 36 C, 70 % 83.00 85.80
- 45 C, 40 % 72.00 85.00
- 45 C, 90 % 83.00 95.00
Mamdani vs Sugeno
MODULE 3 · COMPARISON
REAL OUTPUT: L23/COMPARE.PY
- input Mamdani Sugeno
- 20 C, 50 % 50.00 50.00
- 30 C, 40 % 45.04 45.88
- 33 C, 60 % 80.56 83.00
- 36 C, 70 % 82.78 83.00
- 42 C, 35 % 65.46 66.50
- Work per input:
- Mamdani: 5 clipped sets x 101 points, max, centroid
- Sugeno: 5 products, 2 sums, 1 division
Choose: Mamdani when people must read the rules; Sugeno for fast control and for learning from data (ANFIS, P11).
Choosing a Method in Practice
MODULE 3 · USES
Mamdani
Sugeno
Sugeno + learning
Rules people can read and check: a crop-disease advisor for Burewala cotton, expert systems (L19).
Fast control in small chips: inverter AC, cruise control. Smooth output, few calculations.
ANFIS learns the formulas and membership functions from data - P11a/P11b this week.
Activity: Inference by Hand
CLASS ACTIVITY · PAIRS · 8 MIN
Pairs, 6 min + 2 min check. Use the fan rules of S06 and your calculator.
Put in order: aggregate, fuzzify, defuzzify, implication, apply operators.
First-order: w = 0.5, z = 30 + t with t = 35; w = 0.5, z = 15. Output?
36 °C, 70 %: comfortable, hot, dry degrees? Which rule fires? Sugeno output?
Flat top from 20 to 60 at height 0.5. SOM, MOM, LOM?
Sugeno: strengths 0.2 (z = 17), 0.6 (z = 50), 0.2 (z = 83). Output?
Mamdani or Sugeno? (a) doctors must check the rules (b) a tiny chip in an AC
Common Mistakes
WATCH OUT
WRONG IDEA
CORRECT IDEA
✗ Only the strongest rule matters.
✓ All firing rules contribute; aggregation joins them.
✗ Fuzzy AND of 0.33 and 0.67 is 0.22.
✓ Standard AND is min: 0.33.
✗ Sugeno divides by the number of rules.
✓ Divide by the sum of strengths Σ wi.
✗ Mamdani clips the input set.
✓ It clips the OUTPUT (THEN) set at the strength.
✗ Defuzzify each rule, then average.
✓ Mamdani aggregates first, then defuzzifies once.
Recap Quiz
CHECK YOUR UNDERSTANDING · 3 MIN
- Q1. The step that turns a fuzzy set into one number is:
- (a) Fuzzification (b) Implication (c) Aggregation (d) Defuzzification
- Q2. Strength of 'comfortable (0.33) AND NOT dry (dry = 0.33)':
- (a) 0.11 (b) 0.33 (c) 0.67 (d) 1.0
- Q3. In a zero-order Sugeno system the THEN-part is:
- (a) A fuzzy set (b) A constant (c) A linear formula (d) A probability
- Q4. Strengths 0.5 (z = 20) and 0.5 (z = 80). Sugeno output:
- (a) 40 (b) 50 (c) 60 (d) 100
Homework and Next Lecture
BEFORE THE NEXT CLASS
- Task 1: Fan rules at 32 °C, 30 % humidity: find the degrees, the five firing strengths and the zero-order Sugeno output (show the weighted average).
- Task 2: Same input, first-order outputs: slow 15, medium 30 + t, fast 50 + 0.8t + 0.1h. Output?
- Task 3: Aggregated set {0.2/10, 0.5/30, 0.5/50, 0.8/70, 0.3/90}. Centroid and MOM?
NEXT LECTURE
- Lecture 24:
- Machine Learning: Supervised, Unsupervised and Reinforcement