---
title: "Play golf: ID3 and Naive Bayes"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:play-golf-id3-naive-bayes"
source: https://www.bctengineer.com/q/semester_7/data_mining/play-golf-id3-naive-bayes
site: BCT Engineering
---

# Play golf: ID3 and Naive Bayes

Data Mining · Chapter 3: Classification

- Asked in: year not given
- Video: [1. Solved Example Naive Bayes Classifier to classify New Instance PlayTennis Example Mahesh Huddar](https://www.youtube.com/watch?v=XzSlEA4ck2I) — Mahesh Huddar
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/play-golf-id3-naive-bayes
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

Consider the following data set (Play Golf Data). Use "ID3 algorithm" and "Naïve Bayes Classifier" to predict if people will play golf on a
   a. Hot, Sunny day with high humidity and no wind.
   b. Cool, rainy day with normal humidity and no wind
   c. Mild, overcast, windy day with normal humidity

| SN | Outlook | Temperature (Numeric) | Temperature (Nominal) | Humidity (Numeric) | Humidity (Nominal) | Windy | Class: Play |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | Overcast | 83 | Hot | 86 | High | False | Yes |
| 2 | Overcast | 64 | Cool | 65 | Normal | True | Yes |
| 3 | Overcast | 72 | Mild | 90 | High | True | Yes |
| 4 | Overcast | 81 | Hot | 75 | Normal | False | Yes |
| 5 | Rainy | 70 | Mild | 96 | High | False | Yes |
| 6 | Rainy | 68 | Cool | 80 | Normal | False | Yes |
| 7 | Rainy | 65 | Cool | 70 | Normal | True | No |
| 8 | Rainy | 75 | Mild | 80 | Normal | False | Yes |
| 9 | Rainy | 71 | Mild | 91 | High | True | No |
| 10 | Sunny | 85 | Hot | 85 | High | False | No |
| 11 | Sunny | 80 | Hot | 90 | High | True | No |
| 12 | Sunny | 72 | Mild | 95 | High | False | No |
| 13 | Sunny | 69 | Cool | 70 | Normal | False | Yes |
| 14 | Sunny | 75 | Mild | 70 | Normal | True | Yes |

## Short answer

Root node is outlook. ID3 predicts: (a) No, (b) Yes, (c) Yes. Naïve Bayes gives the same: (a) No, (b) Yes, (c) Yes.

## Answer

**Assumption**: the nominal columns (Temperature = Hot/Mild/Cool, Humidity = High/Normal) are used, and the numeric columns are ignored. Windy = False means "no wind". Data: 14 records, Play = Yes: 9, No: 5.

#### ID3
Entropy(S) = −(9/14)log₂(9/14) − (5/14)log₂(5/14) = 0.940.

| Attribute | Partitions (Yes, No) | Gain |
| --- | --- | --- |
| Outlook | Overcast (4, 0), Rainy (3, 2), Sunny (2, 3) | **0.247** |
| Temperature | Hot (2, 2), Mild (4, 2), Cool (3, 1) | 0.029 |
| Humidity | High (3, 4), Normal (6, 1) | 0.152 |
| Windy | False (6, 2), True (3, 3) | 0.048 |

Root = **Outlook**. Overcast is pure (Yes).
- Sunny subset (E = 0.971): gains Temp 0.571, **Humidity 0.971**, Windy 0.020. High → No (3), Normal → Yes (2).
- Rainy subset (E = 0.971): gains Temp 0.020, Humidity 0.020, **Windy 0.971**. False → Yes (3), True → No (2).

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

**ID3 predictions**
- a. Sunny, High humidity, no wind (Hot) → Sunny → High → **No**
- b. Rainy, Normal humidity, no wind (Cool) → Rainy → Windy = False → **Yes**
- c. Overcast (Mild, Normal humidity, windy) → **Yes**

#### Naïve Bayes
P(Yes) = 9/14, P(No) = 5/14.

**a. X = (Sunny, Hot, High, Windy = False)**
- Yes: (9/14)(2/9)(2/9)(3/9)(6/9) = **0.00705**
- No: (5/14)(3/5)(2/5)(4/5)(2/5) = **0.02743**
- Normalised: No = 79.5% → **No**

**b. X = (Rainy, Cool, Normal, Windy = False)**
- Yes: (9/14)(3/9)(3/9)(6/9)(6/9) = **0.03175**
- No: (5/14)(2/5)(1/5)(1/5)(2/5) = **0.00229**
- Yes = 93.3% → **Yes**

**c. X = (Overcast, Mild, Normal, Windy = True)**
- Yes: (9/14)(4/9)(4/9)(6/9)(3/9) = **0.02822**
- No: (5/14)(0/5)(2/5)(1/5)(3/5) = **0** (Overcast never occurs with "No")
- With Laplacian correction: Yes = 0.0258, No = 0.0027 → **Yes**

**Answer: (a) No, (b) Yes, (c) Yes, by both ID3 and Naïve Bayes.**

## Check yourself

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

1. Root attribute by ID3 is:
   A. Outlook
   B. Humidity
   C. Windy
   D. Temperature
   Answer: A. Outlook gain 0.247 is highest. (Key point: Root)

2. Which attribute splits the Sunny subset?
   A. Windy
   B. Humidity (High -> No, Normal -> Yes)
   C. Temperature
   D. Outlook
   Answer: B. Humidity gain 0.971. (Key point: Sunny branch)

3. Rainy, normal humidity, no wind (Cool): ID3 says:
   A. No
   B. Undecided
   C. Yes
   D. Depends on temperature
   Answer: C. Rainy -> Windy=False -> Yes. (Key point: Prediction b)

4. Why is the NB No value 0 for query c?
   A. Mild never occurs with No
   B. Windy True never occurs
   C. P(No) = 0
   D. Overcast never occurs with Play = No
   Answer: D. Overcast has count 0 in class No. (Key point: Zero probability)

## Related in Data Mining

- [Buys computer: ID3 and Naive Bayes](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Abuys-computer-id3-naive-bayes) — Data Mining, chapter 3
- [Naive Bayes and Laplacian correction](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Anaive-bayes-laplace) — Data Mining, chapter 3
- [Naive Bayes advantages and disadvantages](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Anaive-bayes-pros-cons) — Data Mining, chapter 3
- [Decision tree classifier and Hunt's algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Adecision-tree-hunt) — 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
- [ID3 algorithm and why greedy](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aid3-greedy) — Data Mining, chapter 3
