---
title: "Rules generation using ID3"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:id3-rules-generation"
source: https://www.bctengineer.com/q/semester_7/data_mining/id3-rules-generation
site: BCT Engineering
---

# Rules generation using ID3

Data Mining · Chapter 3: Classification

- Asked in: year not given, 10 marks; 2066 Bhadra, 3 marks
- Video: [Lec-10: Decision Tree 🌲 ID3 Algorithm with Example & Calculations 🧮](https://www.youtube.com/watch?v=CWzpomtLqqs) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/id3-rules-generation
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

How do you generate rules with ID3? Explain with example.  (Also asked as: write a short note on rules generation using the ID3 technique.)

## Short answer

ID3 builds a decision tree on maximum information gain, then converts each root-to-leaf path into an IF-THEN rule: the tests along the path form the antecedent (AND) and the leaf class the consequent. For example, IF Outlook=Sunny AND Humidity=High THEN Play=No.

## Answer

A decision tree built by ID3 can be converted into **IF-THEN classification rules**. Each path from the root to a leaf gives one rule: the attribute tests along the path are joined by AND to form the condition (antecedent), and the leaf class is the consequent. The rules are mutually exclusive and exhaustive, and are easier for humans to read than a large tree.

#### Procedure
1. Build the tree using ID3: at each node pick the attribute with maximum information gain.
2. Traverse each root-to-leaf path.
3. Write `IF (test1) AND (test2) ... THEN class = leaf`.
4. Optionally simplify: drop a condition if accuracy does not fall (pruning of rules), and remove duplicate rules.

#### Example (Play Golf data, 14 records, 9 Yes, 5 No)
Entropy of the data = 0.940. Gains: Outlook 0.247, Humidity 0.152, Windy 0.048, Temperature 0.029. So Outlook is the root.

```text
Outlook
 |-- Overcast --> Yes
 |-- Sunny    --> Humidity
 |                 |-- High   --> No
 |                 |-- Normal --> Yes
 |-- Rainy    --> Windy
                   |-- False --> Yes
                   |-- True  --> No
```

**Rules generated**
1. IF Outlook = Overcast THEN Play = Yes
2. IF Outlook = Sunny AND Humidity = High THEN Play = No
3. IF Outlook = Sunny AND Humidity = Normal THEN Play = Yes
4. IF Outlook = Rainy AND Windy = False THEN Play = Yes
5. IF Outlook = Rainy AND Windy = True THEN Play = No

Number of rules = number of leaves (5 here). A new tuple is classified by the first rule whose condition it satisfies.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How does one rule come from an ID3 tree?
   A. Each node gives one rule
   B. Only the root gives a rule
   C. Each root-to-leaf path gives one rule: tests joined by AND, leaf class as consequent
   D. Each attribute gives one rule
   Answer: C. The path's attribute tests are ANDed and the leaf class is the THEN part. (Key point: Path to rule)

2. Why is Outlook the root of the Play Golf tree?
   A. It has the lowest information gain
   B. It is the first column
   C. Its gain is 0.940
   D. It has the highest information gain (0.247)
   Answer: D. ID3 picks the maximum-gain attribute; 0.940 is the entropy of the data. (Key point: Root selection)

3. How many rules does the example tree give?
   A. 5, equal to the number of leaves
   B. 4, the number of attributes
   C. 3, the number of Outlook values
   D. 9, the number of Yes records
   Answer: A. One rule per leaf. (Key point: Number of rules)

4. Which statement about the generated rules is true?
   A. They overlap heavily
   B. They are mutually exclusive and exhaustive
   C. They cannot be simplified
   D. They are harder to read than the tree
   Answer: B. Rules can be simplified by dropping conditions without loss in accuracy. (Key point: Rule properties)

## Related in Data Mining

- [Overfitting in ID3 and decision tree rules](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aid3-overfitting-rules) — Data Mining, chapter 3
- [ID3 steps, overfitting, TP/FP/recall](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aid3-steps-overfitting-recall) — Data Mining, chapter 3

## Related in other subjects

- [Indicator organism; membrane filter technique](https://www.bctengineer.com/question.md?key=semester_5%2Fwater_supply_engineering%3Aindicator-organisms-membrane-filter) — Water Supply Engineering, chapter 4, asked 2×
- [Zones of protection and their rules](https://www.bctengineer.com/question.md?key=semester_6%2Fswitchgear_and_protection%3Azones-of-protection) — Switchgear and Protection, chapter 1, asked 2×
- [Rules of inference: movie and sunset](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Arules-inference-rainy-movie) — Discrete Structure, chapter 1
- [Rules of inference: sailing race](https://www.bctengineer.com/question.md?key=semester_4%2Fdiscrete_structure%3Arules-inference-sailing-race) — Discrete Structure, chapter 1
