public class C45 extends Algorithm
correct, log, modelDataset, modelFileName, resultFileName, startTime, testCorrect, testDataset, testFileName, testOutputFileName, trainDataset, trainFileName, trainOutputFileName
Constructor and Description |
---|
C45(MyDataset data,
boolean pruned,
float cf,
int minItemsets)
Parameter constructor.
|
C45(parseParameters paramFile)
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(MyDataset itemsets)
Generates the tree.
|
Tree |
getTree()
Returns the C4.5 tree
|
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 options)
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(parseParameters paramFile) throws java.lang.Exception
paramFile
- The parameters file.java.lang.Exception
- If the algorithm cannot be executed.public C45(MyDataset data, boolean pruned, float cf, int minItemsets) throws java.lang.Exception
data
- data to constructor the model.pruned
- true if prune method will be applied.cf
- confidence value.minItemsets
- minimum items per leaf.java.lang.Exception
- if the model can not be built.protected void setOptions(java.io.StreamTokenizer options) throws java.lang.Exception
setOptions
in class Algorithm
options
- The StreamTokenizer that reads the parameters file.java.lang.Exception
- If the format of the file is not correct.public void generateTree(MyDataset 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 cannot compute the classification.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
public Tree getTree()