Thursday, February 19, 2009

Naive Bayesian Classifiers in Java - II

Class diagram



Sequence diagram

Screenshot from the application

(screenshot with loaded training data for the example “playing tennis” )

There are three classes left , which fulfil control tasks.

MyRadioButtonListener:
This class is an inner class of the NaiveBayesApplication class, it implements the java.awt.event.ActionListener interface. There is instanciated one listener for every RadioButton. The task of ths listeners is to keep the stringkeys vector of the NaiveBayesApplication consistent to the selected RadioButtons.

WindowCloser:
This class implements the java.awt.event.WindowListener interface. The instanced object is responsible for shutting down the application when the user closes the application window.

XMLFileFilter:This class inherits from the javax.swing.filechooser.FileFilter class. The instanced object is responsible that only XML-files are shown, when the user loads new training data.Training Data Input via XML

An XML-file, which represents training data for the NaiveBayesApplication must have a special format.
Such an XML-file must have three tags. The first one is the tag, which contains a string representing the domain. The second one is the tag, which contains subtags which describe the attributes and their possible values. Since I map the attribute values in a hashtable with a string as key, two different attributes are not allowed to have equal values. The third tag is the tag, which contains a number of tags which represent the real training data. For more information please look at the example training data XML-files.

As example training data I chose the “Playing Tennis” example from [1] and created an new example “Accident”.
The “Playing Tennis” has the following attributes (outlook, temperature, humidity, wind) and the two classifications (playing , not playing).
The “Accident” example has the attributes (status of driver, status of road, sight, driving license for more than 5 years) and the two classifications (accident, no accident).
It is certainly arguable if these examples make any sense or represent any real data, but the used training datas are not the subject of this seminar work
.

How to run the program
To get this application running you need the jdk1.3 or higher and the package[2] which provides the DOMparser I’ve used. You must add the path of this package to your Classpath variable, then the application should work.

No comments:

Post a Comment