Professional Documents
Culture Documents
Arbre Decision 2324 4p 1 11
Arbre Decision 2324 4p 1 11
Etant donné :
- Unlangage pour représenter les exemples ℒ" : features (x,y)
- Un espace d’instances #, représentables dans ce langage
- Un langage d’hypothèses ℒℎ (une fonction de # ↦ & )
On cherche :
h ∈ ℒℎ tq pour tout ") = +), -) , ℎ ") ≈ /)
[These slides were created by Dan Klein, Pieter Abbeel, Sergey Levine. All CS188 materials are at http://ai.berkeley.edu.]
§ Problem:
§ Given a hypothesis space H
§ Given a training set of examples xi
§ Find a hypothesis h(x) such that h ~ f
§ Includes:
§ Classification (outputs = class labels)
§ Regression (outputs = real numbers)
Méthodologie en Apprentissage Inductif Modelling a learning problem : Features
§ True function
§ Realizable: in H
Decision Tree Learning Choosing an Attribute
§ Aim: find a small tree consistent with the training examples § Idea: a good attribute splits the examples into subsets that are (ideally) “all positive” or
§ Idea: (recursively) choose “most significant” attribute as root of (sub)tree “all negative”
§ So: we need a measure of how “good” a split is, even if the results aren’t perfectly
separated out
Learning&simplest(decision&tree&is&NPThard&
Expressiveness of DTs
Entropy& High,&Low&Entropy&
Entropy&H(Y)&of&a&random&variable&Y
• “High&Entropy”&&
– Y&is&from&a&uniform&like&distribuGon&
Entropy&of&a&coin&flip& – Flat&histogram&
– Values&sampled&from&it&are&less&predictable&
More uncertainty, more entropy!
• “Low&Entropy”&&
Entropy&
Entropy&Example& CondiGonal&Entropy&
Entropy&
CondiGonal&Entropy&H( Y |X)&of&a&random&variable&Y&condiGoned&on&a&
random&variable&X
Probability&of&heads&
X1 X2 Y
P(Y=t) = 5/6 Example: X1
X1 X2 Y t f T T T
P(Y=f) = 1/6 T F T
T T T P(X1=t) = 4/6 Y=t : 4 Y=t : 1
T F T P(X1=f) = 2/6 Y=f : 0 T T T
H(Y) = - 5/6 log2 5/6 - 1/6 log2 1/6 Y=f : 1
T T T T F T
= 0.65 T F T F T T
H(Y|X1) = - 4/6 (1 log2 1 + 0 log2 0)
F T T - 2/6 (1/2 log2 1/2 + 1/2 log2 1/2) F F F
F F F = 2/6
InformaGon&gain& Entropy
• Decrease&in&entropy&(uncertainty)&a_er&spli^ng&
§ General answer: if prior is <p1,…,pn>:
§ Information is the expected code length
1 bit
X1 X2 Y
In our running example: T T T
IG(X1) = H(Y) – H(Y|X1) T F T
§ Also called the entropy of the distribution 0 bits
= 0.65 – 0.33 T T T § More uniform = higher entropy
T F T § More values = higher entropy
§ More peaked = lower entropy
IG(X1) > 0 ! we prefer the split! F T T
F F F 0.5 bit
Information Gain Next Step: Recurse
§ Back to decision trees! § Now we need to keep growing the tree!
§ For each split, compare entropy before and after § Two branches are done (why?)
§ Difference is the information gain
§ Problem: there’s more than one distribution after split! § What to do under “full”?
§ See what examples are there…
A?
Gini(N1) Gini(N2)
Yes No
= 1 – (3/3)2 – (0/3)2 = 1 – (4/7)2 – (3/7)2
=0 = 0.490
Node N1 Node N2
Gini(Children)
= 3/10 * 0
+ 7/10 * 0.49
= 0.343
48
52 52
1.2 Jeux d’entraînement et de test Règle d’or
— Erreur de généralisation : erreur que l’on peut attendre sur de nouvelles
données (la définition formelle fait appel à l’espérance)
— Elle est estimée en mettant de côté une partie des données :
— On sépare les données en un jeu d’entraînement et un jeu de test
(typiquement, 80%–20%) NE PAS TOUCHER au jeu de test
Jeu de données sauf pour évaluer l’erreur de généralisation du modèle
Entraînement Test
54
1.3 Validation croisée 1.3 Validation croisée
Bloc 1 Bloc 2 Bloc 3 Bloc 4 Bloc 5 Bloc 1 Bloc 2 Bloc 3 Bloc 4 Bloc 5
Test 1 Entraînement 1
Bloc 1 Bloc 2 Bloc 3 Bloc 4 Bloc 5 Bloc 1 Bloc 2 Bloc 3 Bloc 4 Bloc 5
55 56
1.4 Évaluation d’un modèle (classification) 1.4 Évaluation d’un modèle (classification)
Classe réelle
0 1
Classe 0 Vrais Négatifs (TN) Faux Négatifs (FN)
prédite 1 Faux Positifs (FP) Vrais Positifs (TP)
56 56