Skip to main content

Extracting rules from decision tree

Short answer

For each path from root to leaf, create a rule with all attribute-value tests along the path combined with AND, and the leaf class as the consequent. For instance: IF age=youth AND student=no THEN buys_computer=no. The resulting rules are mutually exclusive and exhaustive, with as many rules as leaves.

How can rules be extracted from decision tree? Explain with an example.

A decision tree can be converted into a set of IF-THEN rules, which are easier to read than a large tree.

Method

  1. Create one rule for each path from the root to a leaf.
  2. Each attribute-value test along the path is a condition; the tests are combined with AND.
  3. The leaf class label is the rule's consequent (THEN part).
  4. (Optional) Simplify the rules: remove a condition if this does not reduce rule accuracy (pessimistic estimate), and remove duplicate or redundant rules.

The rules from an unpruned tree are mutually exclusive (a record satisfies only one rule) and exhaustive (every record is covered). The number of rules equals the number of leaves.

Example (buys-computer tree)

            age?
      young/ middle \senior
     student?  YES   credit_rating?
     no/  \yes       fair/    \excellent
     NO   YES        YES       NO

Rules:

  1. IF age = young AND student = no THEN buys_computer = no
  2. IF age = young AND student = yes THEN buys_computer = yes
  3. IF age = middle THEN buys_computer = yes
  4. IF age = senior AND credit_rating = fair THEN buys_computer = yes
  5. IF age = senior AND credit_rating = excellent THEN buys_computer = no

Rule 3 has only one condition because its leaf is reached by a single test. The rule set is equivalent to the tree.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Mining chapter 3 questions →