Concept Learning and Decision Trees With Extra Notes - 1
Concept Learning and Decision Trees With Extra Notes - 1
[read Chapter 2]
[suggested exercises 2.2, 2.3, 2.4, 2.6]
Sky Temp Humid Wind Water Forecst EnjoySpt
Sunny Warm Normal Strong Warm Same Yes
• Learning from examples Sunny Warm High Strong Warm Same Yes
Rainy Cold High Strong Warm Change No
• General-to-specific ordering over hypotheses Sunny Warm High Strong Cool Change Yes
1 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 2 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Representing Hypotheses Prototypical Concept Learning Task
Sky Temp Humid Wind Water Forecst EnjoySpt Sky Temp Humid Wind Water Forecst EnjoySpt
Sunny Warm Normal Strong Warm Same Yes Sunny Warm Normal Strong Warm Same Yes
Sunny Warm High Strong Warm Same Yes Sunny Warm High Strong Warm Same Yes
Rainy Cold High Strong Warm Change No Rainy Cold High Strong Warm Change No
Sunny Warm High Strong Cool Change Yes Sunny Warm High Strong Cool Change Yes
Classify everything negative • Determine: A hypothesis h in H such that h(x) = c(x) for all x in D.
⟨φ, φ, φ, φ, φ, φ⟩
3 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 4 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Instance, Hypotheses, and More-
General-Than
Specific
h h
x1 1 3
h
x 2
2
General
x1= <Sunny, Warm, High, Strong, Cool, Same> h 1= <Sunny, ?, ?, Strong, ?, ?>
x = <Sunny, Warm, High, Light, Warm, Same> h = <Sunny, ?, ?, ?, ?, ?>
2 2
h = <Sunny, ?, ?, ?, Cool, ?>
3
5 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 6 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Find-S Algorithm Hypothesis Space Search by Find-S
3. Output hypothesis h
-
h0 Specific
x3
h1
h 2,3
x 1+ x+
2
x4+ h General
4
h = <∅, ∅, ∅, ∅, ∅, ∅>
0
x 1 = <Sunny Warm Normal Strong Warm Same>, + h1 = <Sunny Warm Normal Strong Warm Same>
x 2 = <Sunny Warm High Strong Warm Same>, + h2 = <Sunny Warm ? Strong Warm Same>
x 3 = <Rainy Cold High Strong Warm Change>, - h = <Sunny Warm ? Strong Warm Same>
3
x = <Sunny Warm High Strong Cool Change>, + h = <Sunny Warm ? Strong ? ? >
4 4
THEN guarantees most specific hypothesis in H that is consistent with the positive examples
also consistent with the negative examples provided target concept ∈ H, training examples correct
7 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 8 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Complaints about Find-S Version Spaces
• Can’t tell whether it has learned concept A hypothesis h is consistent with a set of training examples D of target concept c if and only
if h(x) = c(x) for each training example ⟨x, c(x)⟩ in D.
• Can’t tell when training data inconsistent
Consistent(h, D) ≡ (∀⟨x, c(x)⟩ ∈ D) h(x) = c(x)
• Picks a maximally specific h (why?)
• Depending on H, there might be several!
The version space, V SH,D , with respect to hypothesis space H and training examples D, is
the subset of hypotheses from H consistent with all training examples in D.
9 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 10 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
The List-Then-Eliminate Algorithm: Example Version Space
<Sunny, ?, ?, Strong, ?, ?> <Sunny, Warm, ?, ?, ?, ?> <?, Warm, ?, Strong, ?, ?>
11 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 12 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Concept Learning As Search Representing Version Spaces
Sky Temp Humid Wind Water Forecst EnjoySpt The General boundary, G, of version space V SH,D is the set of its maximally general members
Sunny Warm Normal Strong Warm Same Yes
Sunny Warm High Strong Warm Same Yes The Specific boundary, S, of version space V SH,D is the set of its maximally specific members
Rainy Cold High Strong Warm Change No
Sunny Warm High Strong Cool Change Yes
Every member of the version space lies between these boundaries
• # classifications
– 296
– 5120
• ⟨., ., φ, ., ., .⟩
– represents no instance
– 975
When large hypothesis space H (possibly infinite) then efficient search strategies required to find
hypothesis that best fits the data.
13 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 14 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Candidate Elimination Algorithm Example Trace
• If d is a negative example
G 0: {<?, ?, ?, ?, ?, ?>}
15 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 16 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
What Next Training Example? How Should These Be Classified?
<Sunny, ?, ?, Strong, ?, ?> <Sunny, Warm, ?, ?, ?, ?> <?, Warm, ?, Strong, ?, ?> <Sunny, ?, ?, Strong, ?, ?> <Sunny, Warm, ?, ?, ?, ?> <?, Warm, ?, Strong, ?, ?>
G: { <Sunny, ?, ?, ?, ?, ?>, <?, Warm, ?, ?, ?, ?> } G: { <Sunny, ?, ?, ?, ?, ?>, <?, Warm, ?, ?, ?, ?> }
Note: Answer comes from nature or teacher ⟨Sunny W arm N ormal Light W arm Same⟩
# experiments: log2 |V S|
17 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 18 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
A Biased Hypothesis Space What Justifies this Inductive Leap?
Example Sky Temp Humid Wind Water Forecst EnjoySpt + ⟨Sunny W arm N ormal Strong Cool Change⟩
1 Sunny Warm Normal Strong Cool Change Yes
2 Cloudy Warm Normal Strong Cool Change Yes + ⟨Sunny W arm N ormal Light W arm Same⟩
3 Rainy Warm Normal Strong Cool Change No
S : ⟨Sunny W arm N ormal ? ? ?⟩
19 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 20 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
An UNBiased Learner Inductive Bias
Consider
Idea: Choose H that expresses every teachable concept (i.e., H is the power set of X)
• concept learning algorithm L
Consider H ′ = disjunctions, conjunctions, negations over previous H. E.g.,
• instances X, target concept c
⟨Sunny W arm N ormal ? ? ?⟩ ∨ ¬⟨? ? ? ? ? Change⟩
• training examples Dc = {⟨x, c(x)⟩}
What are S, G in this case? • let L(xi , Dc ) denote the classification assigned to the instance xi by L after training on data Dc .
S←
Definition:
G←
The inductive bias of L is any minimal set of assertions B such that for any target concept c
and corresponding training examples Dc
21 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 22 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Inductive Systems and Equivalent De- Three Learners with Different Biases
ductive Systems
Inductive system 1. Rote learner: Store examples, Classify x iff it matches previously observed example.
Inductive bias
made explicit
23 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 24 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Summary Points Decision Tree Learning
[read Chapter 3]
1. Concept learning as search through H [recommended exercises 3.1, 3.4]
2. General-to-specific ordering over H • Decision tree representation
3. Version space candidate elimination algorithm • ID3 learning algorithm
4. S and G boundaries characterize learner’s uncertainty • Entropy, Information gain
5. Learner can generate useful queries • Overfitting
6. Inductive leaps possible only if learner is biased
7. Inductive learners can be modelled by equivalent deductive systems
25 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 26 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Decision Tree for P layT ennis A Tree to Predict C-Section Risk
No Yes No Yes
The instance
• Outlook = Sunny
• Temperature = Hot
• Humidity = High
• Wind = Strong
→ No
27 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 28 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Decision Trees When to Consider Decision Trees
29 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 30 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Top-Down Induction of Decision Entropy
Trees
1.0
Main loop:
1. A ← the “best” decision attribute for next node
2. Assign A as decision attribute for node
Entropy(S)
3. For each value of A, create new descendant of node
4. Sort training examples to leaf nodes 0.5
5. If training examples perfectly classified, Then STOP, Else iterate over new leaf nodes
31 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 32 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Entropy Information Gain
Entropy(S) = expected number of bits needed to encode class (⊕ or ⊖) of randomly drawn member of S Gain(S, A) = expected reduction in entropy due to sorting on A
(under the optimal, shortest-length code)
! |Sv |
Why? Gain(S, A) ≡ Entropy(S) − Entropy(Sv )
|S|
v∈V alues(A)
Information theory: optimal length code assigns − log2 p bits to message having probability p.
33 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 34 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Training Examples Selecting the Next Attribute
S: [9+,5-] S: [9+,5-]
E =0.940 E =0.940
Humidity Wind
35 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 36 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
{D1, D2, ..., D14} Hypothesis Space Search by ID3
[9+,5−]
Outlook
...
A2 A2
Which attribute should be tested here?
+ – + – + – + –
A3 A4
Ssunny = {D1,D2,D8,D9,D11} –
+
Gain (Ssunny , Humidity) = .970 − (3/5) 0.0 − (2/5) 0.0 = .970
Gain (Ssunny , Temperature) = .970 − (2/5) 0.0 − (2/5) 1.0 − (1/5) 0.0 = .570 ... ...
Gain (Ssunny , Wind) = .970 − (2/5) 1.0 − (3/5) .918 = .019 ID3 algorithms perform a single to complex hill-climbing searching
37 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 38 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Hypothesis Space Search by ID3 Inductive Bias in ID3
39 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 40 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Occam’s Razor Overfitting in Decision Trees
Why prefer short hypotheses? Consider adding noisy training example #15:
Argument opposed:
• There are many ways to define small sets of hyps Sunny Overcast Rain
• e.g., all trees with a prime number of nodes that use attributes beginning with “Z”
• What’s so special about small sets based on size of hypothesis?? Humidity Yes Wind
No Yes No Yes
41 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 42 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Overfitting Overfitting in Decision Tree Learning
Accuracy
0.7
0.65
0.5
0 10 20 30 40 50 60 70 80 90 100
Size of tree (number of nodes)
43 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 44 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Avoiding Overfitting Reduced-Error Pruning
How can we avoid overfitting? Split data into training and validation set
• stop growing when data split not statistically significant Do until further pruning is harmful:
• grow full tree, then post-prune 1. Evaluate impact on validation set of pruning each possible node (plus those below it)
2. Greedily remove the one that most improves validation set accuracy
How to select “best” tree:
• Measure performance over training data
• produces smallest version of most accurate subtree
• Measure performance over separate validation data set
• What if data is limited?
• MDL: minimize size(tree) + size(misclassif ications(tree))
45 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 46 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Effect of Reduced-Error Pruning Rule Post-Pruning
0.9
1. Convert tree to equivalent set of rules
0.7
0.65
0.5
0 10 20 30 40 50 60 70 80 90 100
Size of tree (number of nodes)
47 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 48 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Converting A Tree to Rules Continuous Valued Attributes
No Yes No Yes
...
49 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 50 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Attributes with Many Values Attributes with Costs
Problem: Consider
• If attribute has many values, Gain will select it • medical diagnosis, BloodT est has cost $150
• Imagine using Date = Jun 3 1996 as attribute • robotics, W idth f rom 1f t has cost 23 sec.
SplitInf ormation(S, A) ≡ −
-c
! |Si |
log2
|Si | • Nunez (1988)
|S| |S| 2Gain(S,A) − 1
i=1
(Cost(A) + 1)w
where Si is subset of S for which A has value vi where w ∈ [0, 1] determines importance of cost
51 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997 52 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997
Unknown Attribute Values
53 c
lecture slides for textbook Machine Learning, ⃝Tom M. Mitchell, McGraw Hill, 1997