Decision Tree Learning
Decision Tree Learning
(IS ZC464)
BITS Pilani
Pilani Campus
BITS Pilani
Pilani Campus
Lecture No. 9
Date 20/02/2016
Time 2:00 PM 4:00 PM
Todays agenda
4
IS ZC464, Machine Learning
20 February 2016
Decision Tree
A decision tree is a structure that includes
A root node,
Set of branches, and
Set of leaf nodes
Set of Each internal node.
5
IS ZC464, Machine Learning
20 February 2016
Decision Tree
A Decision tree is used for classification.
Each internal node denotes a test on an attribute
Each branch denotes the outcome of a test, and
Each leaf node holds a class label.
6
IS ZC464, Machine Learning
20 February 2016
Decision Tree
Decision tree is for the
concept buy_compute
that indicates whether a
customer at a company
is likely to buy a
computer or not.
20 February 2016
7
BITS Pilani, Pilani Campus
20 February 2016
Benefits
It does not require any domain knowledge.
It is easy to understood.
The learning and classification steps of a decision tree are simple
and fast.
9
IS ZC464, Machine Learning
20 February 2016
Outlook
Temperature
Humidity
Wind
PlayTennis
D1
Sunny
Hot
High
Weak
No
D2
Sunny
Hot
High
Strong
No
D3
Overcast
Hot
High
Weak
Yes
D4
Rain
Mild
High
Weak
Yes
D5
Rain
Cool
Normal
Weak
Yes
D6
Rain
Cool
Normal
Strong
No
D7
Overcast
Cool
Normal
Strong
Yes
D8
Sunny
Mild
High
Weak
No
D9
Sunny
Cool
Normal
Weak
Yes
D10
Rain
Mild
Normal
Weak
Yes
D11
Sunny
Mild
Normal
Strong
Yes
D12
Overcast
Mild
High
Strong
Yes
D13
Overcast
Hot
Normal
Weak
Yes
D14
Rain
Mild
High
Strong
No
10
IS ZC464, Machine Learning
20 February 2016
11
IS ZC464, Machine Learning
20 February 2016
20 February 2016
20 February 2016
Outlook = Overcast
14
IS ZC464, Machine Learning
20 February 2016
20 February 2016
20 February 2016
20 February 2016
18
IS ZC464, Machine Learning
20 February 2016
19
IS ZC464, Machine Learning
20 February 2016
20 February 2016
20 February 2016
21
22
IS ZC464, Machine Learning
20 February 2016
23
IS ZC464, Machine Learning
20 February 2016
24
IS ZC464, Machine Learning
20 February 2016
25
IS ZC464, Machine Learning
20 February 2016
26
IS ZC464, Machine Learning
20 February 2016
ID3(Attr, Q, S) {
If S is empty, returns a single node with value failure.
If S consists of examples of same class, return a single leaf node with that values.
If Attr is empty, then return a single node with the value of the most frequent value of Q
in S.
{
A ChooseBestAttribute (S, Attr)
Tree A new decision tree rooted at A
For each value vj of A do
Sj Subset of S with A = vj
Subt ID3(Attr A, Q, Sj)
Add a branch to tree with
label vj and sub-tree subt
Return tree
}
27
20 February 2016
Outlook
Temperature
Humidity
Wind
PlayTennis
D1
Sunny
Hot
High
Weak
No
D2
Sunny
Hot
High
Strong
No
D3
Overcast
Hot
High
Weak
Yes
D4
Rain
Mild
High
Weak
Yes
D5
Rain
Cool
Normal
Weak
Yes
D6
Rain
Cool
Normal
Strong
No
D7
Overcast
Cool
Normal
Strong
Yes
D8
Sunny
Mild
High
Weak
No
D9
Sunny
Cool
Normal
Weak
Yes
D10
Rain
Mild
Normal
Weak
Yes
D11
Sunny
Mild
Normal
Strong
Yes
D12
Overcast
Mild
High
Strong
Yes
D13
Overcast
Hot
Normal
Weak
Yes
D14
Rain
Mild
High
Strong
No
20 February 2016
28
Outlook
Temperature
Humidity
Wind
PlayTennis
D15
Rain
Hot
High
Weak
???
29
IS ZC464, Machine Learning
20 February 2016
Outlook
Temperature
Humidity
Wind
PlayTennis
D1
Sunny
Hot
High
Weak
No
D2
Sunny
Hot
High
Strong
No
D3
Overcast
Hot
High
Weak
Yes
D4
Rain
Mild
High
Weak
Yes
D5
Rain
Cool
Normal
Weak
Yes
D6
Rain
Cool
Normal
Strong
No
D7
Overcast
Cool
Normal
Strong
Yes
D8
Sunny
Mild
High
Weak
No
D9
Sunny
Cool
Normal
Weak
Yes
D10
Rain
Mild
Normal
Weak
Yes
D11
Sunny
Mild
Normal
Strong
Yes
D12
Overcast
Mild
High
Strong
Yes
D13
Overcast
Hot
Normal
Weak
Yes
D14
Rain
Mild
High
Strong
No
20 February 2016
30
Outlook
Overcast
(4 Yes/0 No)
Sunny
(2 Yes/3 No)
Day
Temperature
Humidity
Wind
PlayTennis
D3
Hot
High
Weak
Yes
D7
Cool
Normal
Strong
Yes
D12
Mild
High
Strong
Yes
D13
Hot
Normal
Weak
Yes
Rain
(3 Yes/2 No)
Day
Temperature
Humidity
Wind
PlayTennis
Day
Temperature
Humidity
Wind
PlayTennis
D1
Hot
High
Weak
No
D4
Mild
High
Weak
Yes
D2
Hot
High
Strong
No
D5
Cool
Normal
Weak
Yes
D8
Mild
High
Weak
No
D6
Cool
Normal
Strong
No
D9
Cool
Normal
Weak
Yes
D10
Mild
Normal
Weak
Yes
D11
Mild
Normal
Strong
Yes
D14
Mild
High
Strong
No
20 February 2016
31
Outlook
Overcast
Sunny
Rain
Yes
(4 Yes/0 No)
(2 Yes/3 No)
(3 Yes/2 No)
Day
Temperature
Humidity
Wind
PlayTennis
D4
Mild
High
Weak
Yes
No
D5
Cool
Normal
Weak
Yes
Weak
No
D6
Cool
Normal
Strong
No
Normal
Weak
Yes
D10
Mild
Normal
Weak
Yes
Normal
Strong
Yes
D14
Mild
High
Strong
No
Day
Temperature
Humidity
Wind
PlayTenni
s
D1
Hot
High
Weak
No
D2
Hot
High
Strong
D8
Mild
High
D9
Cool
D11
Mild
20 February 2016
32
Outlook
Overcast
Sunny
Yes
Rain
(4 Yes/0 No)
(2 Yes/3 No)
(3 Yes/2 No)
Day
Temperature
Humidity
Wind
PlayTennis
D4
Mild
High
Weak
Yes
No
D5
Cool
Normal
Weak
Yes
Weak
No
D6
Cool
Normal
Strong
No
Normal
Weak
Yes
D10
Mild
Normal
Weak
Yes
Normal
Strong
Yes
D14
Mild
High
Strong
No
Day
Temperature
Humidity
Wind
PlayTenni
s
D1
Hot
High
Weak
No
D2
Hot
High
Strong
D8
Mild
High
D9
Cool
D11
Mild
20 February 2016
33
Sunny
Overcast
(2 Yes/3 No)
Yes
Rain
(4 Yes/0 No)
Humidity
Normal
High
(3 Yes/2 No)
(0 Yes/3 No)
Day
(9 Yes/5 No)
(2 Yes/0 No)
Tempera
ture
Wind
PlayTennis
D1
Hot
Weak
No
D2
Hot
Strong
No
D8
Mild
Weak
No
Day
Temper
ature
Wind
Play
Ten
nis
D9
Cool
Weak
Yes
D11
Mild
Stron
g
Yes
20 February 2016
Day
Temperature
Humidity
Wind
PlayTennis
D4
Mild
High
Weak
Yes
D5
Cool
Normal
Weak
Yes
D6
Cool
Normal
Strong
No
D10
Mild
Normal
Weak
Yes
D14
Mild
High
Strong
No
34
Outlook
Sunny
Overcast
(2 Yes/3 No)
Yes
(4 Yes/0 No)
Humidity
High
No
(0 Yes/3 No)
Rain
Normal
(3 Yes/2 No)
Yes
(2 Yes/0 No)
20 February 2016
Day
Temperature
Humidity
Wind
PlayTennis
D4
Mild
High
Weak
Yes
D5
Cool
Normal
Weak
Yes
D6
Cool
Normal
Strong
No
D10
Mild
Normal
Weak
Yes
D14
Mild
High
Strong
No
35
Outlook
Sunny
Overcast
(2 Yes/3 No)
Yes
(4 Yes/0 No)
Humidity
High
No
(0 Yes/3 No)
Rain
Normal
(3 Yes/2 No)
Yes
(2 Yes/0 No)
20 February 2016
Day
Temperature
Humidity
Wind
PlayTennis
D4
Mild
High
Weak
Yes
D5
Cool
Normal
Weak
Yes
D6
Cool
Normal
Strong
No
D10
Mild
Normal
Weak
Yes
D14
Mild
High
Strong
No
36
Outlook
Rain
Sunny
Overcast
Wind
(2 Yes/3 No)
Yes
(4 Yes/0 No)
Humidity
High
No
(0 Yes/3 No)
Weak
(3 Yes/0 No)
Normal
Yes
(2 Yes/0 No)
Day
Temperature
Humidity
PlayTennis
D4
Mild
High
Yes
D5
Cool
Normal
Yes
D10
Mild
Normal
Yes
Strong
(0 Yes/2 No)
Day
Temperature
Humidity
PlayTennis
D6
Cool
Normal
No
D14
Mild
High
No
37
IS ZC464, Machine Learning
20 February 2016
(9 Yes/5 No)
Rain
Sunny
Overcast
Wind
(2 Yes/3 No)
Yes
Humidity
Weak
(4 Yes/0 No)
High
No
(0 Yes/3 No)
Strong
Normal
Yes
(2 Yes/0 No)
Yes
(3 Yes/0 No)
No
(0 Yes/2 No)
38
IS ZC464, Machine Learning
20 February 2016
Outlook
Rain
Sunny
Overcast
Wind
(2 Yes/3 No)
Yes
Humidity
Weak
(4 Yes/0 No)
Strong
Normal
High
No
Yes
(0 Yes/3 No)
Yes
(2 Yes/0 No)
Day
D15
IS ZC464, Machine Learning
Outlook
Rain
Temperature
Hot
20 February 2016
No
(3 Yes/0 No)
(0 Yes/2 No)
Humidity
Wind
PlayTennis
High
Weak
???
39
Outlook
Rain
Sunny
Overcast
Wind
(2 Yes/3 No)
Yes
Humidity
Weak
(4 Yes/0 No)
Strong
Normal
High
No
Yes
(0 Yes/3 No)
Yes
(2 Yes/0 No)
Day
D15
IS ZC464, Machine Learning
Outlook
Rain
Temperature
Hot
20 February 2016
No
(3 Yes/0 No)
(0 Yes/2 No)
Humidity
Wind
PlayTennis
High
Weak
???
40
Outlook
Rain
Sunny
Overcast
Wind
(2 Yes/3 No)
Yes
Humidity
Weak
(4 Yes/0 No)
Strong
Normal
High
No
Yes
(0 Yes/3 No)
Yes
(2 Yes/0 No)
Day
D15
IS ZC464, Machine Learning
Outlook
Rain
Temperature
Hot
20 February 2016
No
(3 Yes/0 No)
(0 Yes/2 No)
Humidity
Wind
PlayTennis
High
Weak
???
41
Outlook
Rain
Sunny
Overcast
Wind
(2 Yes/3 No)
Yes
Humidity
Weak
(4 Yes/0 No)
Strong
Normal
High
No
Yes
(0 Yes/3 No)
Yes
(2 Yes/0 No)
Day
D15
IS ZC464, Machine Learning
Outlook
Rain
Temperature
Hot
20 February 2016
No
(3 Yes/0 No)
(0 Yes/2 No)
Humidity
Wind
PlayTennis
High
Weak
Yes
42
43
IS ZC464, Machine Learning
20 February 2016
44
IS ZC464, Machine Learning
20 February 2016
45
IS ZC464, Machine Learning
20 February 2016
46
IS ZC464, Machine Learning
20 February 2016
47
IS ZC464, Machine Learning
20 February 2016
48
IS ZC464, Machine Learning
20 February 2016
20 February 2016
Outlook
Temperature
Humidity
Wind
PlayTennis
D1
Sunny
Hot
High
Weak
No
D2
Sunny
Hot
High
Strong
No
D3
Overcast
Hot
High
Weak
Yes
D4
Rain
Mild
High
Weak
Yes
D5
Rain
Cool
Normal
Weak
Yes
D6
Rain
Cool
Normal
Strong
No
D7
Overcast
Cool
Normal
Strong
Yes
D8
Sunny
Mild
High
Weak
No
D9
Sunny
Cool
Normal
Weak
Yes
D10
Rain
Mild
Normal
Weak
Yes
D11
Sunny
Mild
Normal
Strong
Yes
D12
Overcast
Mild
High
Strong
Yes
D13
Overcast
Hot
Normal
Weak
Yes
D14
Rain
Mild
High
Strong
No
Wind = Weak
[6 yes, 2 No]
Wind = Strong
[3 yes, 3 No]
50
IS ZC464, Machine Learning
20 February 2016
Wind = Weak
[6 yes, 2 No]
Wind = Strong
[3 yes, 3 No]
51
IS ZC464, Machine Learning
20 February 2016
Wind = Weak
[6 yes, 2 No]
Wind = Strong
[3 yes, 3 No]
20 February 2016
Wind = Weak
[6 yes, 2 No]
Wind = Strong
[3 yes, 3 No]
20 February 2016
20 February 2016
54
20 February 2016
55
20 February 2016
57
IS ZC464, Machine Learning
20 February 2016
58
IS ZC464, Machine Learning
20 February 2016
59
IS ZC464, Machine Learning
20 February 2016
Temperature
Humidity
Wind
PlayTennis
D1
Hot
High
Weak
No
D2
Hot
High
Strong
No
D8
Mild
High
Weak
No
D9
Cool
Normal
Weak
Yes
D11
Mild
Normal
Strong
Yes
60
IS ZC464, Machine Learning
20 February 2016
(9 Yes/5 No)
Rain
Sunny
Overcast
Wind
(2 Yes/3 No)
Yes
Humidity
Weak
(4 Yes/0 No)
High
No
(0 Yes/3 No)
Strong
Normal
Yes
(2 Yes/0 No)
Yes
(3 Yes/0 No)
No
(0 Yes/2 No)
61
IS ZC464, Machine Learning
20 February 2016
ID3:Decision Tree
ID3 performs no backtracking in its search (greedy algorithm).
Once an attribute has been chosen as the node for a particular
level of the tree, ID3 does not reconsider this choice.
62
IS ZC464, Machine Learning
20 February 2016
ID3:Decision Tree
As ID3 searches through the space of decision trees, it maintains
only a single current hypothesis.
By learning only a single hypothesis, ID3 loses benefits
associated with explicitly representing all consistent
hypotheses.
For instance, it does not have the ability to
determine how many decision trees that are
consistent with the data could exist, or select the
best hypothesis among these.
63
IS ZC464, Machine Learning
20 February 2016
ID3:Decision Tree
64
IS ZC464, Machine Learning
20 February 2016
Thank You