public class TreeNode
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<java.lang.Integer> |
deleteDescendants(int original_identifier)
Removes the descendants from a identifier given of a node.
|
boolean |
equals(java.lang.Object obj)
Checks if a node is the same node as another object
|
int |
evaluate(double[] ind,
java.util.ArrayList<myAttribute> atts)
Classifies a given item with the information stored in the node and its descendants
|
Split |
getCondition()
Gets the relationship between this node and its descendats, that's the way to split this node in two
|
int |
getIdentifier()
Gets the identifier of the node
|
int |
getLeafs()
Gets the number of leaf nodes from this node and its descendants
|
TreeNode |
getLeft()
Gets the left descendant of the node, if it is not a leaf node
|
TreeNode |
getNode(int id)
Searches a descendant node from this node with a specific id
|
int |
getNumNodes()
Gets the number of internal nodes from this node and its descendants.
|
int |
getOutputClass()
Gets the output class stored for the node.
|
TreeNode |
getRight()
Gets the right descendant of the node, if it is not a leaf node
|
int |
hashCode()
Hash-code function for the class that is used when object is inserted in a structure like a hashtable
|
boolean |
isLeaf()
Answers if the node is a leaf node or not
|
java.lang.String |
printTree(java.util.ArrayList<myAttribute> atts,
myAttribute outputAttribute)
Prints the tree in a String with all the information that makes it human readable
|
void |
setCondition(Split condition)
Replaces the relationship between this node and its descendants, this means, changing the condition how
the two descendants are created.
|
void |
setIdentifier(int identifier)
Replaces the identifier of the node with another new node
|
void |
setLeaf(boolean isLeaf)
Changes the logical attribute stating if a node is leaf or not
|
void |
setLeft(TreeNode left)
Replaces the left descendant of the node with another new left descendant
|
void |
setOutputClass(int outputClass)
Replaces the output class of the node with another new output class
|
void |
setRight(TreeNode right)
Replaces the right descendant of the node with another new right descendant
|
java.lang.String |
toString()
Overriden function that converts the class to a string
|
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- Object that is checked to see if it is the same nodeObject.equals(java.lang.Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.lang.String printTree(java.util.ArrayList<myAttribute> atts, myAttribute outputAttribute)
atts
- Attributes used in the dataset for building the tree that are needed to change
the numberical information stored in the tree to words informationoutputAttribute
- Attribute used for the class in the dataset for building the tree
that is needed in a similar way to the attributespublic int getIdentifier()
public void setIdentifier(int identifier)
identifier
- New identifier for the nodepublic TreeNode getLeft()
public void setLeft(TreeNode left)
left
- New node that is going to be kept as left descendant of this nodepublic TreeNode getRight()
public void setRight(TreeNode right)
right
- New node that is going to be kept as right descendant of this nodepublic boolean isLeaf()
public void setLeaf(boolean isLeaf)
isLeaf
- Logical value stating if a node is leaf or notpublic int getOutputClass()
public void setOutputClass(int outputClass)
outputClass
- New output class for the nodepublic Split getCondition()
public void setCondition(Split condition)
condition
- New relationship between this node and its descendantspublic TreeNode getNode(int id)
id
- Identifier of the node we are searching forpublic int getNumNodes()
public int getLeafs()
public int evaluate(double[] ind, java.util.ArrayList<myAttribute> atts)
ind
- Data attribute values for the item we are classifyingatts
- Attributes in the data set that are used for building the tree and describing the
instance givenpublic java.util.ArrayList<java.lang.Integer> deleteDescendants(int original_identifier)
original_identifier
- Identifier of the node that is becoming a leaf node and whose descendants
are being removed