public class ID3 extends Algorithm
correct, log, modelDataset, modelFileName, resultFileName, startTime, testCorrect, testDataset, testFileName, testOutputFileName, trainDataset, trainFileName, trainOutputFileName
Constructor and Description |
---|
ID3(java.lang.String paramFile)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
alreadyUsedToDecompose(keel.Algorithms.Decision_Trees.ID3.Node node,
int attribute,
int value)
Function to check if the specified attribute and value are already used to decompose the data.
|
double |
computeEntropy(java.util.Vector data)
Function to compute the entropy of the set of data points.
|
void |
decomposeNode(keel.Algorithms.Decision_Trees.ID3.Node node)
Function to decompose the specified node.
|
int |
evaluateItemset(Itemset itemset,
keel.Algorithms.Decision_Trees.ID3.Node node)
Function to evaluate the class which the itemset must have according to the classification of the tree.
|
void |
generateTree()
Run the algorithm.
|
int[] |
getAllValues(java.util.Vector data,
int attribute)
Function to return all the values of the specified attribute in the data set.
|
java.lang.String |
getCommonClass(java.util.Vector data,
int attribute)
Function to return the most common class of the itemsets in data.
|
java.util.Vector |
getComplement(java.util.Vector data,
java.util.Vector oldset)
Function to returns a subset of data, which is the complement of the second argument.
|
java.util.Vector |
getSubset(java.util.Vector data,
int attribute,
int value)
Function to returns a subset of data.
|
static void |
main(java.lang.String[] args)
Main function.
|
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.
|
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 |
writeTree(keel.Algorithms.Decision_Trees.ID3.Node node,
java.lang.String tab)
Function to write the decision tree in the form of rules.
|
getHeader, initTokenizer
public ID3(java.lang.String paramFile)
paramFile
- The parameters file.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()
public java.lang.String writeTree(keel.Algorithms.Decision_Trees.ID3.Node node, java.lang.String tab)
node
- The current node.tab
- The indentation of the current rule.public int evaluateItemset(Itemset itemset, keel.Algorithms.Decision_Trees.ID3.Node node)
itemset
- The itemset to evaluate.node
- The node that is evaluated at this time.public int[] getAllValues(java.util.Vector data, int attribute)
data
- All the itemsets.attribute
- Number of attributes.public java.lang.String getCommonClass(java.util.Vector data, int attribute)
data
- All the itemsets.attribute
- Index of attribute.public java.util.Vector getSubset(java.util.Vector data, int attribute, int value)
data
- The itemsets that where to extract the subset.attribute
- The attribute to make the division.value
- The value of the attribute.public java.util.Vector getComplement(java.util.Vector data, java.util.Vector oldset)
data
- The itemsets that where to extract the subset.oldset
- The complement set.public double computeEntropy(java.util.Vector data)
data
- The set of itemsets over is wanted to compute the entropy.public boolean alreadyUsedToDecompose(keel.Algorithms.Decision_Trees.ID3.Node node, int attribute, int value)
node
- The node to check at this time.attribute
- The attribute to check.value
- The value to check.public void decomposeNode(keel.Algorithms.Decision_Trees.ID3.Node node)
node
- The node to decompose.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 static void main(java.lang.String[] args)
args
- The parameters file.