

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due date : Friday, April 16, 2004 – beginning of class Description : For this assignment, you will implement a simple version of the ID3 decision tree algorithm. This is the basic algorithm discussed in your book, using information gain as the splitting criteria. You may write this program in either Lisp or Prolog: your choice. Your code will need to do several things:
Prolog: To use the program you’ll do something like the following: attributes([outlook, temperature, humidity, windy]). domains([[sunny, overcast, rain], [cool, mild, hot], [high, normal], [true, false]]). A list of examples would look like: [['-', [sunny, hot, high, false]], ['-', [sunny, hot, high, true]], ['+', [overcast, hot, high, false]], [ '+', [rain, mild, high, false]], ['+', [rain, cool, normal, false]], ['-', [rain, cool, normal, true]], ['+', [overcast, cool, normal, true]], [ '-', [sunny, mild, high, false]], ['+', [sunny, cool, normal, false]], ['+', [rain, mild, normal, false]], ['+', [sunny, mild, normal, true]], ['+', [overcast, mild, high, true]], ['+', [overcast, hot, normal, false]] ['-', [rain, mild, high, true]]] What the tree should look like printed out: If you really want to, you can print the tree in a standard tree format, but a simpler suggestion would be something like the following: OUTLOOK = SUNNY HUMIDITY = NORMAL => YES = HIGH => NO = OVERCAST => YES = RAIN WIND = STRONG => NO = WEAK => YES Notes: The basic function or predicate to construct a decision tree is recursive. The base case will produce a leaf node. You should write a predicate to compute the entropy of a set of examples given the number of positive examples and number of negative examples. Both sicstus and clisp provide a logarithm. In both languages, you probably want to use format to print. Both languages provide ways to get the length of a list and to get a particular member of a list. In sicstus, that will require the lists library (which was used in program 3). You might want to start by thinking about what a tree is going to look like. In lisp, you would probably use a list-based representation. In prolog you could use lists or structures and lists.