Skip to main content

Play golf: ID3 and Naive Bayes

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.

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

SNOutlookTemperature (Numeric)Temperature (Nominal)Humidity (Numeric)Humidity (Nominal)WindyClass: Play
1Overcast83Hot86HighFalseYes
2Overcast64Cool65NormalTrueYes
3Overcast72Mild90HighTrueYes
4Overcast81Hot75NormalFalseYes
5Rainy70Mild96HighFalseYes
6Rainy68Cool80NormalFalseYes
7Rainy65Cool70NormalTrueNo
8Rainy75Mild80NormalFalseYes
9Rainy71Mild91HighTrueNo
10Sunny85Hot85HighFalseNo
11Sunny80Hot90HighTrueNo
12Sunny72Mild95HighFalseNo
13Sunny69Cool70NormalFalseYes
14Sunny75Mild70NormalTrueYes

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.

AttributePartitions (Yes, No)Gain
OutlookOvercast (4, 0), Rainy (3, 2), Sunny (2, 3)0.247
TemperatureHot (2, 2), Mild (4, 2), Cool (3, 1)0.029
HumidityHigh (3, 4), Normal (6, 1)0.152
WindyFalse (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).
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.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Mining chapter 3 questions →