Computer Science 315
Artificial Intelligence
Assignment 5 - AIMIA Chapter 18: Learning from Observations
Did you ever have to finally decide
Say yes to one and let the other one ride
There's so many changes and tears you must hide
Did you ever have to finally decide?
–
The Lovin' Spoonful,
"Did You Ever Have to Make Up Your Mind" (1965)
Due Friday, 09 November
Implement the DECISION-TREE-LEARNING algorithm (Figure 18.5, page 658) in Python,
as a class named DTL contained in a file dtl.py.
Here's the DTL API. The following code will be
useful in writing DTL:
- tree.py   (API)  
- general tree class with formatted output
- attr_table.py   (API)  
- attribute table class with formatted output
The following code will help you test your DTL:
- restaurant.py
- the restaurant example from the book
- andtest.py
- boolean AND function, requiring no information theory
- example.py
- data structure for representing examples
You should write dtl.py following the interface provided. Note that you must also implement
the constructor for this class, as well as a test function, to make decisions on novel examples. Your
restaurant decision tree should give the right answer
for the novel examples. Initially, you should just write your CHOOSE-ATTRIBUTE function
to return the first attribute in attributes. Then you can modify the function to use information
theory, as described on pages 659-660 (Choosing Attribute Tests). In particular,
you should choose the attribute with the maximum gain. My code (andtest.py,
restaurant.py) will test your code with some examples, but you should also
do a "reality check": for each example in the table on page 656, make sure that
your tree makes the right decision. If your test function breaks on
the examples I've set up, there is not necessarily a bug in your code; the
problem could be caused by numerical precision differences on different
systems. If this happens, and you're convinced that your learning function
works, edit the last lines of Restaurant.py to reflect the kind of tree you
built, and send me Restaurant.py along with dtl.py. Of course, you should
check that your tree makes sense!