13
1 A ttributes G oal Exam ple Fri H un P at P rice Rain R es Type E st W illW ait X 1 No Y es S om e $$$ No Y es French 0-10 Y es X 2 No Y es Full $ No No Thai 30-60 No X 3 No No S om e $ No No B urger 0-10 Y es X 4 Y es Y es Full $ No No Thai 10-30 Y es X 5 Y es No Full $$$ No Y es French >60 No X 6 No Y es S om e $$ Y es Y es Italian 0-10 Y es X 7 No No N one $ Y es No B urger 0-10 No X 8 No Y es S om e $$ Y es Y es Thai 0-10 Y es X 9 Y es No Full $ Y es No B urger >60 No X 10 Y es Y es Full $$$ No Y es Italian 10-30 No X 11 No No N one $ No No Thai 0-10 No X 12 Y es Y es Full $ No No B urger 30-60 Y es The Restaurant Domain l they wait, or not?

1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

Embed Size (px)

Citation preview

Page 1: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

1

Attributes GoalExample Fri Hun Pat Price Rain Res Type Est WillWait

X1 No Yes Some $$$ No Yes French 0-10 Yes

X2 No Yes Full $ No No Thai 30-60 No

X3 No No Some $ No No Burger 0-10 Yes

X4 Yes Yes Full $ No No Thai 10-30 Yes

X5 Yes No Full $$$ No Yes French >60 No

X6 No Yes Some $$ Yes Yes Italian 0-10 Yes

X7 No No None $ Yes No Burger 0-10 No

X8 No Yes Some $$ Yes Yes Thai 0-10 Yes

X9 Yes No Full $ Yes No Burger >60 No

X10 Yes Yes Full $$$ No Yes Italian 10-30 No

X11 No No None $ No No Thai 0-10 No

X12 Yes Yes Full $ No No Burger 30-60 Yes

The Restaurant Domain

Will they wait, or not?

Page 2: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

2

Decision TreesPatrons?

No Yes WaitEst?

No Alternate? Hungry? Yes

Reservation? Fri/Sat? Alternate?Yes

NoYesBar? Yes

YesNo

Raining?Yes

YesNo

nonesome

full

>60 30-60 10-300-10

no yes no yes

no yes no yes no yes

no yes no yes

Page 3: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

3

Inducing Decision Trees

Start at the root with all examples.If there are both positive and negative examples, choose an attribute to split them.

If all remaining examples are positive (or negative), label with Yes (or No).

If no example exists, determine label according to majority in parent.

If no attributes left, but you still have both positive and negative examples, you have a problem...

Page 4: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

4

Inducing decision trees

Patrons?

+- X7, X11

nonesome

full

+ X1, X3, X4, X6, X8, X12- X2, X5, X7, X9, X10, X11

+X1, X3, X6, X8-

+X4, X12- X2, X5, X9, X10

Type?

+ X1- X5

FrenchItalian Thai

+X6- X10

+X3, X12- X7, X9

+ X4,X8- X2, X11

Burger

Page 5: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

5

Continuing Induction

Patrons?

+- X7, X11

nonesome

full

+ X1, X3, X4, X6, X8, X12- X2, X5, X7, X9, X10, X11

+X1, X3, X6, X8-

+X4, X12- X2, X5, X9, X10

No Yes Hungry?

+ X4, X12- X2, X10

+- X5, X9

Page 6: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

6

Final Decision Tree

Patrons?

No Yes Hungry?

Type?

Fri/Sat?

No

Yes

Yes

YesNo

No

nonesome

full

>60 No Yes

French Italian

no yes

Thai burger

Page 7: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

7

Decision Trees: summary

Finding optimal decision tree is computationally intractable.

We use heuristics: Choosing the right attribute is the key. Choice based

on information content that the attribute provides.Represent DNF boolean formulas.Work well in practice.What do do with noise? Continuous attributes?

Attributes with large domains?

Page 8: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

8

Choosing an Attribute:Disorder vs. Homogeneity

Bad

Good

Page 9: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

9

The Value of Information

If you control the mail, you control information

Information theory enables to quantify the discriminating value of an attribute.

It will rain in Seattle tomorrow (Boring)We’ll have an earthquake tomorrow (ok, I’m listening)The value of a piece of information is inversely

proportional to its probability.

- Seinfeld

Page 10: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

10

Information Theory

We quantify the value of knowing E as -Lg2 Prob(E) .

If E1,…,En are the possible outcomes of an event, then the value of knowing the outcome is:

Examples: P( 1/2, 1/2) = -1/2 Lg (1/2) - 1/2 Lg 1/2 = 1 P(0.99, 0.01) = 0.08

n

i

iin ELgEEPEPI1

1 )Pr()Pr())(),...,((

Page 11: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

11

Why Should We care?

Suppose we have p positive examples, and n negative ones.

If I classify an example for you as positive or negative, then I’m giving you information:

Now let’s calculate the information you would need after I gave you the value of the attribute A.

),(np

n

np

pIInitial

Page 12: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

12

The Value of an Attribute

Suppose the attribute can take on n values. For A=vali, there would still be pi positive

examples, and ni neagive examples.

The probability of the A=vali is (pi+ni)/(p+n).Hence, after I tell you the value of A, you

need the following amount of information to classify an example:

),(Remainder1 ii

i

ii

in

i

ii

np

n

np

pI

np

np

Page 13: 1 The Restaurant Domain Will they wait, or not?. 2 Decision Trees Patrons? NoYesWaitEst? No Alternate?Hungry?Yes Reservation?Fri/Sat?Alternate?Yes NoYesBar?Yes

13

The value of an Attribute (cont)

The value of an attribute is the difference between the amount of information to classify before and after, I.e., Initial - Remainder.

Patrons:

Remainder(Patrons) =

+- X7, X11

+X1, X3, X6, X8-

+X4, X12- X2, X5, X9, X10

)6

4,

6

2(

12

6)0,1(

12

4)1,0(

12

2 II