Back to the 2020 paper

Module 3: Classification and Prediction

202014m

Draw decision tree for the following data sets. Use entropy as a node selection mechanism:

Outlook Temp (F) Humidity Windy Class
Rainy Hot High False No
Rainy Hot High True No
Overcast Hot High False Yes
Sunny Mild High False Yes
Sunny Cool Normal False Yes
Sunny Cool Normal True No
Overcast Cool Normal True Yes
Rainy Mild High False No
Rainy Cool Normal False Yes
Sunny Mild Normal False Yes
Rainy Mild Normal True Yes
Overcast Mild High True Yes
Overcast Hot Normal False Yes
Sunny Mild High True No
Worked SolutionAI Assisted

Decision Tree for the Weather Data (Entropy-based attribute selection)

Step 1 — Entropy of the root set

14 examples, 9 Yes / 5 No:

H(D)=−914log⁡2914−514log⁡2514≈0.940H(D) = -\frac{9}{14}\log_2\frac{9}{14} - \frac{5}{14}\log_2\frac{5}{14} \approx 0.940

Step 2 — Information gain of each attribute

Gain(A)=H(D)−∑v∣Dv∣∣D∣H(Dv)\text{Gain}(A) = H(D) - \sum_{v}\frac{|D_v|}{|D|} H(D_v)

Outlook

  • Sunny (5: Yes 3, No 2) → 0.971; Overcast (4: Yes 4) → 0; Rainy (5: Yes 2, No 3) → 0.971
  • Gain=0.940−(514(0.971)+414(0)+514(0.971))=0.940−0.694=0.246\text{Gain} = 0.940 - \big(\tfrac{5}{14}(0.971) + \tfrac{4}{14}(0) + \tfrac{5}{14}(0.971)\big) = 0.940 - 0.694 = \mathbf{0.246}

Temperature

  • Hot (4: Yes 2, No 2) → 1.0; Mild (6: Yes 4, No 2) → 0.918; Cool (4: Yes 3, No 1) → 0.811
  • Gain=0.940−(414(1.0)+614(0.918)+414(0.811))=0.940−0.911=0.029\text{Gain} = 0.940 - \big(\tfrac{4}{14}(1.0)+\tfrac{6}{14}(0.918)+\tfrac{4}{14}(0.811)\big) = 0.940 - 0.911 = \mathbf{0.029}

Humidity

  • High (7: Yes 3, No 4) → 0.985; Normal (7: Yes 6, No 1) → 0.592
  • Gain=0.940−(714(0.985)+714(0.592))=0.940−0.789=0.151\text{Gain} = 0.940 - \big(\tfrac{7}{14}(0.985)+\tfrac{7}{14}(0.592)\big) = 0.940 - 0.789 = \mathbf{0.151}

Windy

  • False (8: Yes 6, No 2) → 0.811; True (6: Yes 3, No 3) → 1.0
  • Gain=0.940−(814(0.811)+614(1.0))=0.940−0.892=0.048\text{Gain} = 0.940 - \big(\tfrac{8}{14}(0.811)+\tfrac{6}{14}(1.0)\big) = 0.940 - 0.892 = \mathbf{0.048}

Root = Outlook (highest gain 0.246).

Step 3 — Expand each branch

Overcast branch (4 examples, all Yes) → leaf Yes (pure).

Sunny branch (5 examples: Yes 3, No 2):

Attribute Info Gain
Temp (3/5)(0.918)+(2/5)(1.0) = 0.951 0.020
Humidity (2/5)(1.0)+(3/5)(0.918) = 0.951 0.020
Windy False: all Yes → 0; True: all No → 0; Info = 0 0.971

→ Split on Windy; both children are pure: Windy=False → Yes, Windy=True → No.

Rainy branch (5 examples: Yes 2, No 3):

Attribute Info Gain
Temp (2/5)(0)+(2/5)(1.0)+(1/5)(0) = 0.400 0.571
Humidity High: all No → 0; Normal: all Yes → 0; Info = 0 0.971
Windy (3/5)(0.918)+(2/5)(1.0) = 0.951 0.020

→ Split on Humidity; both children are pure: Humidity=High → No, Humidity=Normal → Yes.

Resulting Decision Tree

                    [Outlook]
            /          |          \
        Sunny      Overcast       Rainy
          |           |             |
        Windy        Yes          Humidity
       /     \                   /        \
   False    True             High        Normal
     |        |                |            |
    Yes      No               No           Yes

Verification

Every leaf is pure, so the tree classifies all 14 training examples correctly (training accuracy 100%). New examples are classified by routing them from the root along the matching attribute values — e.g., (Sunny, Cool, Normal, True) → Outlook=Sunny → Windy=True → No, matching the training example.

The classic textbook result: Outlook is the best root split; within Sunny the differentiator is Windy, and within Rainy it is Humidity.

Similar questions

MACHINE LEARNINGApply the ID3 algorithm on the following data to draw a decision tree. Show the Information Gain at each split. ### Dataset | Outlook | Temperature | Humidity | Windy | PlayTennis | |-----------|-------------|----------|-------|-------------| | Sunny | Hot | High | False | No | | Sunny | Hot | High | True | No | | Overcast | Hot | High | False | Yes | | Rainy | Mild | High | False | Yes | | Rainy | Cool | Normal | False | Yes | | Rainy | Cool | Normal | True | No | | Overcast | Cool | Normal | True | Yes | | Sunny | Mild | High | False | No | | Sunny | Cool | Normal | False | Yes | | Rainy | Mild | Normal | False | Yes | | Sunny | Mild | Normal | True | Yes | | Overcast | Mild | High | True | Yes | | Overcast | Hot | Normal | False | Yes | | Rainy | Mild | High | True | No |202510mArtificial intelligenceConstruct a simple decision tree from the given dataset: | Weather | Temp | Play? | |---|---|---| | Sunny | Hot | No | | Sunny | Cool | Yes | | Rainy | Cool | Yes | | Rainy | Hot | No | Explain your attribute selection criteria.20247mMACHINE LEARNINGFor the Sun Burn data set given below, construct a decision tree. | Name | Hair | Height | Weight | Location | Class | |--------|--------|----------|---------|----------|-------| | Sunita | Blonde | Average | Light | No | Yes | | Anita | Blonde | Tall | Average | Yes | No | | Kavita | Brown | Short | Average | Yes | No | | Sushma | Blonde | Short | Average | No | Yes | | Xavier | Red | Average | Heavy | No | Yes | | Balaji | Brown | Tall | Heavy | No | No | | Ramesh | Brown | Average | Heavy | No | No | | Sweta | Blonde | Short | Light | Yes | No |202314mData MiningBuild a decision tree using the training data in the table given below. Divide the height attribute into ranges as follows : \{0, 1.6\], (1.6, 1.7\], (1.7, 1.8\], (1.8, 1.9\], (1.9, 2.0\], (2.0, 5.0\] | Gender | Height (m) | Class | |:---:|:---:|:---:| | F | 1.6 | Short | | M | 2 | Tall | | F | 1.9 | Medium | | F | 1.88 | Medium | | F | 1.7 | Short | | M | 1.85 | Medium | | F | 1.6 | Short | | M | 1.7 | Short | | M | 2.2 | Tall | | M | 2.1 | Tall | | F | 1.8 | Medium | | M | 1.95 | Medium | | F | 1.9 | Medium | | F | 1.8 | Medium | | F | 1.75 | Medium |20218m
Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.