EBD Classroom μ

Watch a fuzzy rule-based classifier learned with ex-fuzzy decide, one step at a time: fuzzify the measurements, fire the rules, weight them, aggregate per class, and pick the winner. Drag any value and every step updates.

Checking against ex-fuzzy…
Rules use the product AND, as in ex-fuzzy.
1

Fuzzify: from numbers to degrees

Each input variable is covered by overlapping fuzzy sets with everyday names. A crisp value belongs to each set to a degree μ between 0 and 1, read off the membership function. ex-fuzzy places these trapezoids at quantiles of the training data (ticks along the bottom), so neighbouring sets overlap and, at any value, their degrees add up to 1. Drag inside a chart to move the value.

2

Fire the rules

A rule is true to the degree that all of its conditions hold. ex-fuzzy combines the conditions with the product t-norm, so the firing strength is the product of their μ values. A single condition at 0 silences the whole rule; partly true conditions give a partly firing rule.

firing(R) = μ1 × μ2 × … over the conditions of R
3

Weight by trust: the dominance score

Not all rules deserve the same trust. During training ex-fuzzy measures, for each rule, its support (how much of the training data it covers with the right class) and its confidence (how often the class is right when the rule fires). Their product, the dominance score DS, scales the firing strength into the association degree.

association(R) = firing(R) × DS(R), where DS(R) = support(R) × confidence(R)

Bars are scaled to the strongest association for this specimen.

4

Aggregate per class

Several rules can vote for the same class. Their votes are joined with a fuzzy OR, the maximum: a class is as supported as its strongest rule. Normalising the class degrees to sum to 1 gives the probabilities that predict_proba returns.

predict_proba
5

Decide: the winning rule

The class of the single rule with the highest association degree is the prediction (winner takes all). Because one rule decides, every prediction comes with a readable reason.

Experiment

Rule base lab

These are all the rules the genetic algorithm kept. Switch rules off to see what each one contributes: the accuracy and the confusion matrix are recomputed on the spot, and the steps above follow.

Test set: true class (rows) vs predicted (columns)
Explore

Decision map

Every dot is a sample, coloured by its true class; a dark ring marks a sample the rules get wrong. The shaded background shows what the rules would predict across the two chosen variables, holding the other variables at the specimen's values, so it changes as you move the sliders. Click a dot to study it.

Learn

Train your own rules

The rules above were found by ex-fuzzy's genetic algorithm. Change the budget and run it again: fewer rules or shorter rules are easier to read, more search may be more accurate. A new seed gives a different search.

The same in Python

      
Practise

Try this

Theory

Key ideas

Fuzzy set
A set with graded membership. A function μ(x) in [0, 1] says how much x belongs: a 46 mm bill can be 0.4 Medium and 0.6 Long at once.
Linguistic variable
A measured quantity described by a few fuzzy sets with names (Short, Medium, Long). Rules are written with these names, which is what makes them readable.
Trapezoidal membership
μ rises linearly from a to b, is 1 from b to c, and falls to 0 at d. The outer sets are open-ended shoulders.
t-norm (fuzzy AND)
Combines degrees of conditions. ex-fuzzy uses the product: 0.8 AND 0.5 = 0.4. The minimum is another common choice.
Firing strength
The t-norm of a rule's condition degrees: how true the IF part is for this sample.
Support and confidence
Fuzzy versions of the association-rule measures. Support is the rule's average firing over the training data, counting only samples of its class; confidence is the share of the rule's total firing that lands on its class.
Dominance score
Support × confidence. It rewards rules that are both general and precise, and weights the rule at prediction time.
Association degree
Firing strength × dominance score. The quantity rules compete on.
Fuzzy OR (max)
A class's degree is the maximum association among its rules.
Winning rule
The rule with the largest association degree. Its class is the prediction and the rule is the explanation.
Genetic rule search
ex-fuzzy encodes a whole rule base as a chromosome and evolves a population of them, maximising the macro F1 score minus penalties for missing classes and for long rule bases.
Interpretability vs accuracy
Fewer, shorter rules are easier to read and check. The lab above lets you see how much accuracy each rule actually buys.