public class C45 extends Algorithm
correct, log, modelDataset, modelFileName, resultFileName, startTime, testCorrect, testDataset, testFileName, testOutputFileName, trainDataset, trainFileName, trainOutputFileName
Constructor and Description |
---|
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()
Returns the predicted classes for each test instance.
|
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.
|
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
public C45(java.lang.String trainfn, java.lang.String testfn) throws java.lang.Exception
trainfn
- Training data filename.testfn
- Test data filename.java.lang.Exception
- If the algorithm cannot be executed.public int[] getPredictions()
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 data filename.testfn
- Test data 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
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 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