OverviewScheduleResourcesAssignmentsHome

CSC 122: Computer Science II, Spring 2006

Project 4

Decisions, decisions, decisions

Deadline: Thursday, May 11, 5:00 p.m.

Overview:

A decision tree can be viewed as a flow chart or diagram representing a classification system or predictive model. The tree is structured as a sequence of questions, the answers to which trace a path down the tree to a leaf containing the path's classification or prediction. The classification or prediction made by the model can be a qualitative judgment (e.g., these are responders) or a numerical forecast (e.g., sales will increase 15 percent). Decision trees can be used in many ways, from mining data contained in very large databases to making decisions in response to simple yes/no questions. Decision trees can also "learn" by being extended when an incorrect answer is found at the end of a path.

In this assignment you will have the opportunity to build, modify and use binary decision trees. In the tree that you maintain, each internal node is a yes/no question with two children. Leaves contain the results of traversing the various paths. You are to write a Java application that learns about the universe of your choice by asking the user yes/no questions. For example, the program might learn about animals by having the following dialog with its user (user responses are in uppercase; the actual project will communicate by using dialog boxes):

  Think of an animal and I will guess it.

  Does it have legs? YES
  Is it a cat? YES
  I win! Continue? YES

  Think of an animal and I will guess it.

  Does it have legs? NO
  Is it a snake? YES
  I win! Continue? YES

  Think of an animal and I will guess it.

  Does it have legs? NO
  Is it a snake? NO
  I give up. What is it? EARTHWORM
  Please type a question whose answer is yes for an earthworm and no for a snake:
    DOES IT LIVE UNDERGROUND?
  Continue? NO

  Good-bye

The next set of questions might lead to Is it a snake? To which the answer might be no and the question to learn next might be Does it live in water? resulting in another node being added to the tree:

Tree example

It could also be the case that a result might need to be deleted from the tree. For example, if snake is deleted then fish replaces the question Does it live in water?

Finally, once a tree is built, it would be nice to have it persist between the times the application is run. Thus the tree should be able to be saved to a text file and rebuilt by reading that file when the application is launched again. In addition, it should be possible to save and load several different "knowledge bases" (decision trees).

Specification:

The Guessing project has at least four classes:

  1. Driver: Contains the method main, which creates an instance of GuessingGUI and invokes its start method. Driver will be used to run the application stand-alone (not in the BlueJ environment) once you have completed the rest of the project. You should test as you go by using instances of GuessingGUI, Game and the other classes you write.
  2. GuessingGUI: Contains code that creates a Graphical User Interface with components that are used to accomplish interaction with the application(see below). You should study this module carefully as it contains calls to methods corresponding to each of the buttons in the GUI. It also contains methods used by Game: to open a file for reading and for writing.
  3. Game: Contains a minimal amount of uninteresting code corresponding to each of the buttons in the GUI.
  4. DTree: Is a class not yet written. It contains instance variables and methods corresponding to a decision tree class. The tree will have nodes with left and right child references, as well as a String item in which to store a question or a result. The left reference will correspond to the decision YES and the right to the decision NO. You will need to provide methods to: visit the next node (based on YES or NO decision), write a tree to a text file, read and create a tree from a text file, and add a question and a result to the tree (the result will be a leaf). You will receive extra credit if you also implement the delete method described above.
  5. You may choose to write or include additional classes or methods; a DTreeNode class, for example. For each such class and method make sure to provide complete documentation using JavaDoc format.
GUI
The Project and Getting Started:

The Guessing project:

Standards:

Your project should be well-written, neatly-formatted, modular, and well-documented.

Grading:

OverviewScheduleResourcesAssignmentsHome

Valid HTML 4.01!Valid CSS!DePauw University, Computer Science Department, Spring 2006
Maintained by Brian Howard (bhoward@depauw.edu). Last updated