---
title: "ID3 and TP rate, FP rate, precision"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:id3-weka-tp-fp-precision"
source: https://www.bctengineer.com/q/semester_7/data_mining/id3-weka-tp-fp-precision
site: BCT Engineering
---

# ID3 and TP rate, FP rate, precision

Data Mining · Chapter 3: Classification

- Asked in: year not given, 6+6 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-weka-tp-fp-precision
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

Explain with algorithm how ID3 works. The following is the confusion matrix of telephone user's data generated by the ID3 algorithm using WEKA; calculate the TP rate, FP rate and precision.

| a | b | <-- classified as |
| --- | --- | --- |
| 7 | 2 | a = yes |
| 3 | 2 | b = no |

## Short answer

For class yes, TP=7, FN=2, FP=3, TN=2. TP rate = 7/9 = 0.778, FP rate = 3/5 = 0.600, precision = 7/10 = 0.700. For class no, TP rate = 0.400, FP rate = 0.222, precision = 0.500.

## Answer

#### How ID3 works
ID3 (Iterative Dichotomiser 3) grows a decision tree top-down, always splitting on the attribute with the highest information gain, Gain(S, A) = Entropy(S) − Σ (|Sᵥ|/|S|)·Entropy(Sᵥ), with Entropy(S) = −Σ pᵢ log₂ pᵢ.

```text
ID3(S, Attributes, Class)
1. Create a node N.
2. If all examples in S have the same class C
      return N as a leaf labelled C.
3. If Attributes is empty
      return N as a leaf labelled with the majority class of S.
4. For every attribute A compute Gain(S, A).
5. Choose A* with the highest information gain; label N with A*.
6. For each value v of A*:
      Sv = examples of S with A* = v
      if Sv is empty: add a leaf with the majority class of S
      else: add the subtree ID3(Sv, Attributes - {A*}, Class)
7. Return N.
```

Leaves are labelled with the class; a new record is classified by following the tests from the root to a leaf. ID3 is greedy, accepts only categorical attributes, and can overfit.

#### Confusion matrix calculation
Rows are actual classes, columns are the classified ones. Total = 7 + 2 + 3 + 2 = 14.

For class **a = yes** (taken as positive): TP = 7, FN = 2, FP = 3 (actual "no" classified as "yes"), TN = 2.

- TP rate = TP/(TP + FN) = 7/(7 + 2) = 7/9 = **0.778**
- FP rate = FP/(FP + TN) = 3/(3 + 2) = 3/5 = **0.600**
- Precision = TP/(TP + FP) = 7/(7 + 3) = 7/10 = **0.700**

For class **b = no** (taken as positive): TP = 2, FN = 3, FP = 2, TN = 7.
- TP rate = 2/5 = 0.400, FP rate = 2/9 = 0.222, precision = 2/4 = 0.500.

| Class | TP rate | FP rate | Precision |
| --- | --- | --- | --- |
| a = yes | 0.778 | 0.600 | 0.700 |
| b = no | 0.400 | 0.222 | 0.500 |
| Weighted avg. | 0.643 | 0.465 | 0.629 |

Accuracy = (7 + 2)/14 = 64.3%.

**Answer: for the class "yes", TP rate = 0.778, FP rate = 0.600, precision = 0.700.**

## Check yourself

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

1. In the matrix [7 2; 3 2] with 'yes' as positive, what is FP?
   A. 2 (actual yes predicted no)
   B. 7
   C. 3 (actual no predicted yes)
   D. 2 (actual no predicted no)
   Answer: C. FP is the actual 'no' records classified as 'yes'. (Key point: FP definition)

2. What is the TP rate for class yes?
   A. 7/10 = 0.700
   B. 3/5 = 0.600
   C. 7/14 = 0.500
   D. 7/9 = 0.778
   Answer: D. TP/(TP+FN) = 7/(7+2). (Key point: TP rate)

3. What is the FP rate for class yes?
   A. 3/5 = 0.600
   B. 3/10 = 0.300
   C. 2/9 = 0.222
   D. 7/9 = 0.778
   Answer: A. FP/(FP+TN) = 3/(3+2). (Key point: FP rate)

4. What is the precision for class yes?
   A. 7/9 = 0.778
   B. 7/10 = 0.700
   C. 7/14 = 0.500
   D. 3/5 = 0.600
   Answer: B. TP/(TP+FP) = 7/(7+3). (Key point: Precision)

## Related in Data Mining

- [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
- [ID3 algorithm and WEKA confusion matrix](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aid3-algorithm-weka-confusion) — Data Mining, chapter 3
- [Measures from cancer confusion matrix](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aconfusion-matrix-cancer) — Data Mining, chapter 3
- [Confusion matrix and performance measures](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aconfusion-matrix-measures) — Data Mining, chapter 3
- [Measures from confusion matrix (152, 130)](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aconfusion-matrix-152-130) — Data Mining, chapter 3
