public class Tree
extends java.lang.Object
Class to handle the classifier tree
Modifier and Type | Field and Description |
---|---|
protected float |
confidence
The confidence factor for pruning.
|
protected boolean |
isEmpty
Is this node empty or not.
|
protected boolean |
isLeaf
Is this node leaf or not.
|
protected boolean |
isUnexplored
Is this node unexplored or not.
|
protected SelectCut |
model
The selected model.
|
protected Cut |
nodeModel
The model of the node.
|
static int |
NumberOfLeafs
Number of Leafs in the tree
|
static int |
NumberOfNodes
Total number of Nodes in the tree
|
protected boolean |
prune
Is pruned the tree or not.
|
protected Tree[] |
sons
Sons of the node.
|
protected MyDataset |
train
The dataset.
|
Constructor and Description |
---|
Tree()
Constructor.
|
Tree(SelectCut selectNodeModel,
boolean pruneTree,
float cf)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
buildNode(MyDataset data)
Adds one new node.
|
void |
buildTree(MyDataset data)
Function to build the classifier tree.
|
double[] |
classificationForItemset(Itemset itemset)
Function to get the classification of classes.
|
void |
collapse()
Function to collapse a tree to a node if training error doesn't increase.
|
Tree |
getChild(int i)
Returns the son with the given index.
|
int |
getNChildren()
Returns the number of children of the root.
|
protected Tree |
getNewTree(MyDataset data)
Function to create a new tree.
|
boolean |
isUnexplored()
Returns whether the node is unexplore or not.
|
void |
prune()
Function to prune a tree.
|
java.lang.String |
toString()
Function to print the tree.
|
public static int NumberOfNodes
public static int NumberOfLeafs
protected SelectCut model
protected Cut nodeModel
protected Tree[] sons
protected boolean isLeaf
protected boolean isEmpty
protected boolean isUnexplored
protected MyDataset train
protected boolean prune
protected float confidence
public Tree()
public Tree(SelectCut selectNodeModel, boolean pruneTree, float cf)
selectNodeModel
- The cut model.pruneTree
- Prune the tree or not.cf
- Minimum confidence.public void buildNode(MyDataset data) throws java.lang.Exception
data
- The dataset.java.lang.Exception
- If the node cannot be built.public void buildTree(MyDataset data) throws java.lang.Exception
data
- The dataset.java.lang.Exception
- If the tree cannot be built.public final void collapse()
public void prune() throws java.lang.Exception
java.lang.Exception
- If the prune cannot be made.public final double[] classificationForItemset(Itemset itemset) throws java.lang.Exception
itemset
- The itemset to classify.java.lang.Exception
- If the probabilities cannot be computed.public java.lang.String toString()
toString
in class java.lang.Object
protected Tree getNewTree(MyDataset data) throws java.lang.Exception
data
- The dataset.java.lang.Exception
- If the new tree cannot be created.public int getNChildren()
public boolean isUnexplored()
public Tree getChild(int i)
i
- The index of the son.