|
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||
See:
Description
| Interface Summary | |
|---|---|
| DecisionTree | Capable of classifying new data points into categories. |
| DecisionTreeCreator | The learning algorithm for a decision tree. |
| FitnessFunction | Performance measure of a classifier |
| Class Summary | |
|---|---|
| AxialDecisionTree | A decision tree each of whose branches depends on only one attribute. |
| AxialTreeNode | A node in an axial decision tree has two branches and a condition to decide which branch to take. |
| Classify | Uses a trained decision tree to classify cases. |
| FitnessFunction.Split | |
| GainRatioFitnessFunction | Picks a threshold to maximize the gain but uses gain-ratio as the fitness of this attribute |
| GainRatioFitnessFunction.ValueAndCategory | |
| MulticategorySkillScore | Computes and returns skill scores for a multi-category forecast. |
| QuinlanC45AxialDecisionTreeCreator | C45 learning algorithm to create an axial decision tree. |
| Train | Command-line program that invokes Quinlan's C4.5 algorithm |
| Exception Summary | |
|---|---|
| DecisionTreeCreator.TreeCreationException | |
| QuinlanC45AxialDecisionTreeCreator.TreeCreationException | |
Provides classes that implement Quinlan's C4.5 algorithm in Java to train a decision tree based on labeled data (supervised learning) and to classify unlabeled cases using a trained decision tree. The decision tree can be saved using ObjectOutputStream or XMLEncoder (java.beans)
java org.jscience.statistics.decisiontree.Train trainingfile.csv outdir
java org.jscience.statistics.decisiontree.Train trainingfile.csv outdir 0.1 1 " "
java org.jscience.statistics.decisiontree.Train outdir/decisiontree.xml testingfile.csv outdir
The output directory will contain a file in which each line corresponds to the output of the decisiontree
for the set of inputs.
// TRAIN
float[][] data = new float[numTraining][numAttr];
int[] categories = new int[numTraining];
// populate arrays
...
QuinlanC45AxialDecisionTreeCreator classifier = new QuinlanC45AxialDecisionTreeCreator(0.1); // pruning fraction
DecisionTree tree = classifier.learn(data, categories);
// SAVE
import java.beans.XMLEncoder;
XMLEncoder encoder = new XMLEncoder(new FileOutputStream("decisiontree.xml"));
encoder.writeObject(tree);
encoder.close();
// RETRIEVE
import java.beans.XMLDecoder;
XMLDecoder decoder = new XMLDecoder("decisiontree.xml");
AxialDecisionTree tree = (AxialDecisionTree) decoder.readObject();
// CLASSIFY USING TREE
float[] data = new float[numAttr];
// populate array
....
int category = tree.classify(data);
// COMPUTE SKILL
float[][] data = new float[numTesting][numAttr];
int[] categories = new int[numTesting]; // true categories
MulticategorySkillScore tss = new MulticategorySkillScore(tree.getNumCategories());
for (int i=0; i < numTesting; ++i){
int result = tree.classify(data[i]);
tss.update(categories[i], result);
}
float trueSkillScore = tss.getTSS();
|
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||