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 paramFile)
Constructor.
|
C45(java.lang.String fichTrain,
boolean pruned,
float confidence,
int instancesPerLeaf)
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()
It generates the decision tree from the dataset
|
void |
generateTree(Dataset itemsets)
Generates the tree.
|
static void |
main(java.lang.String[] args)
Main function.
|
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.
|
java.lang.String |
printString()
It prints the information related to the decision tree
|
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(java.lang.String paramFile) throws java.lang.Exception
paramFile
- The parameters file.java.lang.Exception
- If the algorithm cannot be executed.public C45(java.lang.String fichTrain, boolean pruned, float confidence, int instancesPerLeaf)
fichTrain
- The input training file.pruned
- indicates if the tree is going to be pruned or notconfidence
- confidenceinstancesPerLeaf
- minimun number of instances per leafpublic void generateTree() throws java.lang.Exception
java.lang.Exception
- if the tree is not generatedprotected 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(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 itemset 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 java.lang.String printString()
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 static void main(java.lang.String[] args)
args
- The parameters file.