Decision Tree by Visualization
Decision Tree by Visualization
Sash Saseetharran
Pre-Requisites
• Part I
Explore data
Visualize
• Part II
Let’s do it together
• Part III
Students try in pairs
• Part IV
Galvanize the understanding
Closing
Part I
Visualize the tree
Predict if Peter will Play Golf?
Day Outlook Temp Humidity Windy Play
1 sunny hot high false No
2 sunny hot high true No
3 overcast hot high false Yes
4 rain mild high false Yes
5 rain cool normal false Yes
6 rain cool normal true No
7 overcast cool normal true Yes
8 sunny mild high false No
9 sunny cool normal false Yes
10 rain mild normal false Yes
11 sunny mild normal true Yes
12 overcast mild high true Yes
13 rain mild high true No
14 rain hot normal false
Predict if Peter will Play ... Contd
Root Node
Predict if Peter will Play Golf?
Day Outlook Temp Humidity Windy Play
1 sunny hot high false No
2 sunny hot high true No
3 overcast hot high false Yes
4 rain mild high false Yes
5 rain cool normal false Yes
6 rain cool normal true No
7 overcast cool normal true Yes
8 sunny mild high false No
9 sunny cool normal false Yes
10 rain mild normal false Yes
11 sunny mild normal true Yes
12 overcast mild high true Yes
13 rain mild high true No
14 rain hot normal false
Decision Tree
8 Yes + 5 No
Outlook Root Node
Overcast
3 Yes + 0 No
Terminal Node (Leaf)
Part II
Let’s do it together!
Decision Tree
8 Yes + 5 No
Outlook Root Node
Overcast
2 Yes + 3 No
More splitting is needed
Decision Tree
8 Yes + 5 No
Outlook Root Node
Overcast
2 Yes + 3 No
More splitting is needed
Decision Tree
8 Yes + 5 No
Outlook Root Node
Overcast
High Humidity ?
no
yes
Overcast
High Humidity ?
yes no
No Yes
(3) (2)
Part III
Students in pairs
(4 mins)
Decision Tree
8 Yes + 5 No
Outlook Root Node
Overcast
3 Yes + 2 No
More splitting is needed
Decision Tree
8 Yes + 5 No
Outlook Root Node
Overcast
3 Yes + 2 No
More splitting is needed
Learned Decision Tree
Outlook Root Node
Overcast
High Humidity ?
Windy ?
yes no
yes no
No Yes
No Yes
(3) (2)
(2) (3)
Terminal Nodes (Leaf)
Prediction?
Outlook Root Node
Overcast
High Humidity ?
Windy ?
yes no
yes no
No Yes
No Yes
(3) (2) (2) (3)
Day Outlook Temp Humidity Windy
14 rain hot normal false
Prediction?
Outlook Root Node
Overcast
High Humidity ?
Windy ?
yes no
yes no
No Yes
No Yes
(3) (2) (2) (3)
Day Outlook Temp Humidity Windy
14 rain hot normal false
Prediction?
Outlook Root Node
Overcast
High Humidity ?
Windy ?
yes no
yes no
No Yes
No Yes
(3) (2) (2) (3)
Day Outlook Temp Humidity Windy
14 rain hot normal false
Prediction?
Outlook
Overcast
High Humidity ?
Windy ?
yes no
yes no
No Yes No Yes
(3) (2) (2) (3)
Day Outlook Temp Humidity Windy
14 rain hot normal false
Part IV
Review
Predict if Peter will Play Golf?
Day Outlook Temp Humidity Windy Play
1 sunny hot high false No
2 sunny hot high true No
3 overcast hot high false Yes
4 rain mild high false Yes
5 rain cool normal false Yes
6 rain cool normal true No
7 overcast cool normal true Yes
8 sunny mild high false No
9 sunny cool normal false Yes
10 rain mild normal false Yes
11 sunny mild normal true Yes
12 overcast mild high true Yes
13 rain mild high true No
14 rain hot normal false
Predict if Peter will Play Golf?
Day Outlook Temp Humidity Windy Play
1 sunny hot high false No
2 sunny hot high true No
3 overcast hot high false Yes
4 rain mild high false Yes
5 rain cool normal false Yes
6 rain cool normal true No
7 overcast cool normal true Yes
8 sunny mild high false No
9 sunny cool normal false Yes
10 rain mild normal false Yes
11 sunny mild normal true Yes
12 overcast mild high true Yes
13 rain mild high true No
14 rain hot normal false
Splitting at the Nodes
Overcast
High Humidity ?
Windy ?
yes no
yes no
No Yes
No Yes
(3) (2)
(2) (3)
Terminal Nodes (Leaf)
Assumptions