1. [Decision Tree] You will build a decision tree to determine whether or not a child…
- User
- [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
I have solved 1.1 for you and computed all necessary values, here they are: Entropy of Play is 1. For Weather we can have sunny, cloudy, or rainy with entropy respectively: 0.9183(1 yes 2 no), 0 (all yes), 0.8113 (1 yes 3 no) So we can compute the information gain for weather as: (0.3 × 0.9183) + (0.3 × 0) + (0.4 × 0.8113) = 0.60001 Information gain for weather is 0.39999. For Temperature we can have Hot, Mild, or Cool with entropy respectively: 1 (2 yes 2 no), 0.971(3 yes 2 no), 0(1 no) (0.4 × 1) + (0.5 × 0.971) + (0.1 × 0) = 0.8855 Information gain for temperature is 0.1145. For Humidity we can have high or normal with entropy respectively: 0.985(3 yes 4 no), 0.9183(2 yes 1 no) (0.7 × 0.985) + (0.3 × 0.9183) = 0.965 Information gain for humidity is 0.035. For Wind we can have weak or strong with entropy respectively: 0.8113(3 yes 1 no), 0.9183(2 yes 4 no) (0.8113 × 0.4) + (0.6 × 0.9183) = 0.8755 Information gain for wind is 0.1245. Weather has the highest information gain so it should be chosen as the root node. All cloudy weather days were given yes to play (3/3), majority sunny days given no (2/3) and majority rainy days given no (3/4).
from this, solve 1.2 with my values
- Assistant