[Decision Tree] You will build a decision tree to determine whether or not a child goes out to
play.
Day Weather Temperature Humanity Wind Play
1 Sunny Hot High Weak No
2 Cloudy Hot High Weak Yes
3 Sunny Mild Normal Strong Yes
4 Cloudy Mild High Strong Yes
5 Rainy Mild High Strong No
6 Rainy Cool Normal Strong No
7 Rainy Mild High Weak Yes
8 Sunny Hot High Strong No
9 Cloudy Hot Normal Weak Yes
10 Rainy Mild High Strong No
1.1 Calculate the information gain for each feature and select the feature with the highest infor-
mation gain to serve as the root of the decision tree. Draw a root and split the ten training data
points into two groups based on the value of the selected root feature.
k∗ = arg max
k
I(Xk; Y ) = H(Y ) − H(Y |Xk)
1.2 Repeat the two procedures: (1) selecting a feature and (2) splitting the data points until the
leaf nodes of the tree achieve complete purity.
1.3 [Extra Points: 10 points] Try pruning your tree. You need to find a subtree (T ′) minimizing
the criterion C(T ′) below. Based on the criterion computation, do you think we need to prune the
tree found in 4.2?
C(T ′) =
T ′
X
τ =1
Q(τ ) + λ · |num of leaves in T ′|
Q(τ ) = entropy of a leaf in T ′ (measure of impurity)
1
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To solve this problem, we are required to build a decision tree for classifying whether a child goes out to play based on the provided dataset. Below is a step-by-step solution to each part of the problem.
1.1 Calculating Information Gain and Selecting the Root Feature
First, we need to calculate the information gain for each feature (Weather, Temperature, Humidity, Wind) and select the feature with the highest information gain as the root of the decision tree.
Step 1: Calculate the Entropy of the Target Variable (Play)
The entropy ( H(Y) ) of the target variable ( Y ) (Play) is calculated using the formula:
[ H(Y) = -\sum_{i} P(y_i) \log_2 P(y_i) ]
We are to prune the tree to minimize the criterion:
[ C(T') = \sum_{\tau=1}^{T'} Q(\tau) + \lambda \cdot \text{(number of leaves in } T') ]
where ( Q(\tau) ) is the entropy of leaf ( \tau ).
Current Tree Analysis:
Number of leaves: 5
All leaves are pure, so ( Q(\tau) = 0 ) for all leaves.
Current cost: ( C(T) = 0 + 5\lambda = 5\lambda )
Considering Pruning Options:
Option: Prune Branches Under "Sunny" and "Rainy"
Treat "Sunny" and "Rainy" as leaves.
"Sunny" leaf (3 instances): Play "No" (2 instances), Play "Yes" (1 instance)
Entropy: 0.9183
"Rainy" leaf (4 instances): Play "No" (3 instances), Play "Yes" (1 instance)
If ( \lambda > 0.8648 ), pruning reduces the cost, and we should prune.
If ( \lambda \leq 0.8648 ), the original tree is better.
Answer:
Based on the criterion computation, we may need to prune the tree found in 1.2 if the value of λ is greater than 0.8648. Pruning will reduce the overall cost C(T′) when λ is sufficiently large, indicating that a simpler tree with fewer leaves (and some impurity) is preferred over a more complex one. Therefore, depending on the specific value of λ, we may need to prune the decision tree to minimize the criterion.