Back to the 2021 paper

Module 3: Classification and Prediction

20218m

Build 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
Worked SolutionAI Assisted

Building a Decision Tree — Height/Gender Data

Step 1: Discretize Height into the given ranges

Gender Height (m) Range Class
F 1.6 (0,1.6] Short
M 2.0 (1.9,2.0] Tall
F 1.9 (1.8,1.9] Medium
F 1.88 (1.8,1.9] Medium
F 1.7 (1.6,1.7] Short
M 1.85 (1.8,1.9] Medium
F 1.6 (0,1.6] Short
M 1.7 (1.6,1.7] Short
M 2.2 (2.0,5.0] Tall
M 2.1 (2.0,5.0] Tall
F 1.8 (1.7,1.8] Medium
M 1.95 (1.9,2.0] Medium
F 1.9 (1.8,1.9] Medium
F 1.8 (1.7,1.8] Medium
F 1.75 (1.7,1.8] Medium

Class distribution: Short = 4, Medium = 8, Tall = 3 (15 tuples).

Step 2: Root entropy

H(D)=−415log⁡2415−815log⁡2815−315log⁡2315≈1.46H(D) = -\frac{4}{15}\log_2\frac{4}{15} -\frac{8}{15}\log_2\frac{8}{15} -\frac{3}{15}\log_2\frac{3}{15} \approx 1.46

Step 3: Choose the best attribute by Information Gain

Splitting on Height ranges (each row of the discretization table):

Range Tuples Classes Entropy
(0,1.6] 2 Short, Short 0
(1.6,1.7] 2 Short, Short 0
(1.7,1.8] 3 Medium ×3 0
(1.8,1.9] 4 Medium ×4 0
(1.9,2.0] 2 Tall, Medium 1
(2.0,5.0] 2 Tall, Tall 0

Weighted entropy =215(1)=0.13= \frac{2}{15}(1) = 0.13; therefore

Gain(Height)=1.46−0.13=1.33\text{Gain(Height)} = 1.46 - 0.13 = 1.33

Splitting on Gender:

  • Female (9): Short 3, Medium 6 → H(F)=0.92H(F) = 0.92, contributes 915⋅0.92=0.55\frac{9}{15}\cdot0.92 = 0.55
  • Male (6): Short 1, Medium 2, Tall 3 → H(M)=1.46H(M) = 1.46, contributes 615⋅1.46=0.58\frac{6}{15}\cdot1.46 = 0.58

Gain(Gender)=1.46−(0.55+0.58)=0.33\text{Gain(Gender)} = 1.46 - (0.55+0.58) = 0.33

Since Gain(Height) = 1.33 > Gain(Gender) = 0.33, split on Height at the root.

Step 4: Resulting Decision Tree

                      Height range?
        ┌──────────────┬────────────┬───────────┬────────--┬──────────┬──────────┐
      (0,1.6]      (1.6,1.7]   (1.7,1.8]  (1.8,1.9]   (1.9,2.0]    (2.0,5.0]
         │             │            │          │           │             │
      Short         Short       Medium     Medium        │           Tall
                                                         │
                                             Height ≥ 2.0 ?
                                            /             \
                                      Tall            Medium
                                     (2.0)            (1.95)

Explanation

  • Every range except (1.9,2.0] is already pure (all classes identical), so it becomes a leaf directly.
  • The range (1.9,2.0] contains two male students: height 2.0 → Tall, height 1.95 → Medium — Gender cannot separate them (both M), so the only distinguishing feature left is a finer height threshold (≥ 2.0 → Tall, else Medium).
  • The final tree separates students into the three classes Short / Medium / Tall using their height, giving perfect classification on this training set.

Similar questions

Data MiningBuild a decision tree using the training data in the table given below. Divide the height attribute into ranges as follows: [0, 1.6], \quad [1.6, 1.7], \quad [1.7, 1.8], \quad [1.8, 1.9], \quad [1.9, 2.0], \quad [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 |20237mMACHINE 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 |202314mMACHINE 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 |202510mData MiningDraw 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 |202014m
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.