public class C45 extends Algorithm
Modifier and Type | Field and Description |
---|---|
protected Dataset |
modelDataset
The model dataset.
|
protected Dataset |
testDataset
The test dataset.
|
protected Dataset |
trainDataset
The train dataset.
|
correct, log, modelFileName, resultFileName, startTime, testCorrect, testFileName, testOutputFileName, trainFileName, trainOutputFileName
Constructor and Description |
---|
C45(InstanceSet trainfn,
InstanceSet testfn)
Constructor.
|
C45(java.lang.String trainfn,
java.lang.String testfn)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
double[] |
classificationForItemset(Itemset itemset)
Returns class probabilities for an itemset.
|
double |
evaluateItemset(Itemset itemset)
Function to evaluate the class which the itemset must have according to the classification of the tree.
|
void |
generateTree(Dataset itemsets)
Generates the tree.
|
int[] |
getPredictions()
Predicted classes for the test instances.
|
double[][] |
getProbabilities()
Classes probabilities for the test instances.
|
static int |
maxIndex(double[] doubles)
Returns index of maximum element in a given array of doubles.
|
void |
printResult()
Writes the tree and the results of the training and the test in the file.
|
void |
printTest()
Evaluates the test dataset and writes the results in the file.
|
void |
printTrain()
Evaluates the training dataset and writes the results in the file.
|
void |
priorsProbabilities()
Sets the class prior probabilities.
|
boolean[] |
selectedTrainingInstances()
Returns a vector including information about which training instances have been selected.
|
protected void |
setOptions(java.io.StreamTokenizer option)
Function to read the options from the execution file and assign the values to the parameters.
|
protected void |
setOptions(java.lang.String trainfn,
java.lang.String testfn)
Function to read the options from the execution file and assign the values to the parameters.
|
java.lang.String |
toString()
Function to print the tree.
|
getHeader, getNextToken, initTokenizer
protected Dataset modelDataset
protected Dataset trainDataset
protected Dataset testDataset
public C45(java.lang.String trainfn, java.lang.String testfn) throws java.lang.Exception
trainfn
- training dataset filenametestfn
- test dataset filenamejava.lang.Exception
- If the algorithm cannot be executed.public C45(InstanceSet trainfn, InstanceSet testfn) throws java.lang.Exception
trainfn
- training datasettestfn
- test datasetjava.lang.Exception
- If the algorithm cannot be executed.public int[] getPredictions()
public double[][] getProbabilities()
protected void setOptions(java.io.StreamTokenizer option) throws java.lang.Exception
Algorithm
setOptions
in class Algorithm
option
- The StreamTokenizer that reads the parameters file.java.lang.Exception
- If the format of the file is not correct.protected void setOptions(java.lang.String trainfn, java.lang.String testfn) throws java.lang.Exception
trainfn
- Training dataset filename.testfn
- Test dataset filename.java.lang.Exception
- If the format of the file is not correct.public void generateTree(Dataset itemsets) throws java.lang.Exception
itemsets
- The dataset used to build the tree.java.lang.Exception
- If the tree cannot be built.public double evaluateItemset(Itemset itemset) throws java.lang.Exception
itemset
- The itemset to evaluate.java.lang.Exception
- if the item can not be evaluated.public final double[] classificationForItemset(Itemset itemset) throws java.lang.Exception
itemset
- The itemset.java.lang.Exception
- If cannot compute the classification.public static int maxIndex(double[] doubles)
doubles
- The array of elements.public void priorsProbabilities() throws java.lang.Exception
java.lang.Exception
- If cannot compute the probabilities.public boolean[] selectedTrainingInstances()
public void printResult() throws java.io.IOException
printResult
in class Algorithm
java.io.IOException
- If the file cannot be written.public void printTrain()
printTrain
in class Algorithm
public void printTest()
public java.lang.String toString()
toString
in class java.lang.Object