Machine Learning Decision Tree – Solved Problem (ID3 algorithm)
Note for the reader: Solving this Decision tree problem took 20 pages. as it is difficult to produce all the matter here, I have attached the solution in PDF document. Please download and check the solution.
Competition Description
Your goal is to find out when people will play outside through next week’s weather forecast. You find out that the reason people decide whether to play or not depends on the weather. The following table is the decision table for whether it is suitable for playing outside.
Data Description
id | outlook | temperature | humidity | wind | play |
1 | sunny | hot | high | weak | no |
2 | sunny | hot | high | strong | no |
3 | overcast | hot | high | weak | yes |
4 | rainy | mild | high | weak | yes |
5 | rainy | cool | normal | weak | yes |
6 | rainy | cool | normal | strong | no |
7 | overcast | cool | normal | strong | yes |
8 | sunny | mild | high | weak | no |
9 | sunny | cool | normal | weak | yes |
10 | rainy | mild | normal | weak | yes |
11 | sunny | mild | normal | strong | yes |
12 | overcast | mild | high | strong | yes |
13 | overcast | hot | normal | weak | yes |
14 | rainy | mild | high | strong | no |
Course Design
Choose your own way and programming language to implement the decision tree algorithm (with code comments or notes). Divide the data in Data Description into training sets and test sets the get your answer.
Solution: I have followed ID 3 (Iterative Dichotomiser 3) Algorithm
We need to construct the Decision tree to predict whether people will play outside or not?
The following Dataset is given in the form of a table
id | outlook | temperature | humidity | wind | play |
1 | sunny | hot | high | weak | no |
2 | sunny | hot | high | strong | no |
3 | overcast | hot | high | weak | yes |
4 | rainy | mild | high | weak | yes |
5 | rainy | cool | normal | weak | yes |
6 | rainy | cool | normal | strong | no |
7 | overcast | cool | normal | strong | yes |
8 | sunny | mild | high | weak | no |
9 | sunny | cool | normal | weak | yes |
10 | rainy | mild | normal | weak | yes |
11 | sunny | mild | normal | strong | yes |
12 | overcast | mild | high | strong | yes |
13 | overcast | hot | normal | weak | yes |
14 | rainy | mild | high | strong | no |
Note for the reader: Solving this Decision tree problem took 20 pages. as it is difficult to produce all the matter here, I have attached the solution in PDF document. Please download and check the solution.