Question: Create a decision tree (code) based on the Discount and Holiday variables to predict the value of Purchase with the following data set. Using weighted
Create a decision tree (code) based on the "Discount" and "Holiday" variables to predict the value of "Purchase" with the following data set. Using weighted gini index as the splitting criteria and show the resulting leaf nodes for each branch of the tree. For the root and each node of the decision tree, calculate the gini index, sample size, and sample distribution. Hint: Sample distribution = [a,b] where a is the number of yes of target value in the current sample, b is the number of no of target value in the current sample
| Holiday | discount | purchase |
|---|---|---|
| no | yes | yes |
| no | yes | yes |
| no | no | no |
| yes | yes | yes |
| yes | yes | yes |
| yes | no | no |
| yes | yes | yes |
| no | yes | yes |
| yes | yes | yes |
| yes | no | yes |
| yes | no | no |
| yes | yes | yes |
| yes | yes | yes |
| yes | yes | yes |
| no | yes | yes |
| yes | no | yes |
| no | yes | yes |
| yes | no | yes |
| yes | no | yes |
| no | yes | yes |
| yes | yes | no |
| yes | no | yes |
| no | yes | yes |
| yes | no | no |
| no | no | no |
| no | yes | yes |
| yes | no | no |
| no | no | no |
| no | yes | yes |
| no | yes | yes |
| yes | yes | yes |
| yes | yes | yes |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
