Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 36 ยท Getting Started

Anatomy of a Fuzzy System

Meet the four parts of every fuzzy inference system, fuzzifier, rule base, inference engine and defuzzifier, and run a complete tiny tipping system in Python.

Every fuzzy system, whether it steers a train or adjusts a washing machine, has the same internal structure. Numbers come in, vague words are applied to them, rules fire, and a number goes out. Knowing this pipeline early gives you a map for the rest of the track: each later lesson zooms into one box of it.

In this lesson you will meet the four components and then run a complete, tiny fuzzy system in Python. Do not worry if some steps feel fast; later lessons slow down and explain each one in detail.

The four components

flowchart LR
    X["Crisp input<br/>service = 7"] --> F["1. Fuzzifier"]
    F --> I["2. Inference engine"]
    R["Rule base<br/>(knowledge)"] --> I
    I --> D["3. Defuzzifier"]
    D --> Y["Crisp output<br/>tip = 17.25 %"]

Input and output are ordinary numbers. Fuzziness lives only in the middle.

  1. Fuzzifier. Converts each crisp input number into degrees of membership in the linguistic terms you defined. A service score of 7 might be "good" to degree 0.33 and "excellent" to degree 0.67. See Fuzzification.
  2. Rule base and inference engine. The rule base holds the expert's knowledge as IF ... THEN ... rules. The inference engine evaluates every rule against the fuzzified inputs and combines the results into one fuzzy output set. See Fuzzy IF-THEN Rules and Mamdani Inference.
  3. Defuzzifier. Turns the fuzzy output set back into a single crisp number that a machine or a person can use. See Defuzzification Methods.

You also need a database of definitions: the universes of discourse (ranges of each variable), the linguistic terms, and their membership functions. Some textbooks draw it as a fourth box; here we treat it as part of the rule base.

The design checklist

Designing a fuzzy system always follows the same steps:

  1. Choose the inputs and outputs and their ranges (for example, service 0 to 10, tip 0 to 25 percent).
  2. Split each variable into linguistic terms such as poor, good, excellent and choose membership functions.
  3. Write the rules.
  4. Pick the operators (AND as minimum or product, how to combine rules, and the defuzzification method).
  5. Test, then tune the shapes and the rules.

A complete tiny system

Here is a full fuzzy system with one input (service quality from 0 to 10) and one output (tip in percent). The rules are:

TEXT
IF service is poor      THEN tip is low
IF service is good      THEN tip is medium
IF service is excellent THEN tip is high

We use the Mamdani style, the classic one: clip each output set at the strength of its rule, combine with maximum, and defuzzify with the centre of gravity (centroid). Read it as a preview; each function appears again, explained, later.

Python A full fuzzy pipeline

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For a service score of 7 the fuzzifier reports "good" to degree 0.33 and "excellent" to degree 0.67. Both rules fire, the "medium" set is clipped low and the "high" set is clipped higher, and the centre of gravity of the combined shape lands between them. That is the whole machine. Change the rules or the membership shapes and the behaviour changes, without touching the engine.

Two families of systems

The system above is of Mamdani type: its output is a fuzzy set, which must be defuzzified. The other well-known family is Sugeno type (also called Takagi-Sugeno-Kang), where each rule outputs a number or a simple formula directly, and the result is a weighted average. It is cheaper to compute and common in control and in tuned systems. Both appear in this chapter series: Mamdani Inference and Sugeno Inference.

Python The same idea, Sugeno style

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The two answers are close but not identical, which is expected: they are different ways to read the same rules.

Why separate the parts?

The strict split into fuzzifier, rules and defuzzifier is what makes fuzzy systems easy to maintain. A domain expert can read and change the rules without touching the engine. An engineer can change the defuzzification method without touching the rules. And a test can feed numbers in and read numbers out, which fits ordinary software testing.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the job of the fuzzifier?

    Fuzzification maps each crisp input value to degrees of membership in every linguistic term of that input.
  2. 2. Which component produces the final crisp output number?

    The defuzzifier converts the aggregated fuzzy output set into a single crisp value.
  3. 3. How does a Sugeno system differ from a Mamdani system?

    In a Sugeno system each rule gives a crisp value or formula and the result is a weighted average, so no separate defuzzification of a shape is needed.
  4. 4. Where does the fuzziness live in a fuzzy system?

    Crisp numbers go in and come out. Fuzzy sets are used inside, between fuzzification and defuzzification.

Summary

  • A fuzzy system is a pipeline: fuzzifier, rule base with inference engine, defuzzifier.
  • A database of linguistic terms and membership functions defines the vocabulary.
  • Designing one means choosing variables, terms, rules, operators, then testing and tuning.
  • Mamdani systems output fuzzy sets that are defuzzified; Sugeno systems output numbers directly.
  • Because the parts are separate, experts can edit rules and engineers can swap methods independently.

Next: Fuzzy Logic vs Probability