public class Node
extends java.lang.Object
Constructor and Description |
---|
Node(int nClases)
Paramenter constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
actualizaClasePrincipal()
Actualizes the main class of the node by considering the frecuency of each class.
|
protected void |
actualizaHistograma(int clase)
Changes an element with the class given from the left leaf to the right one.
|
void |
addChildren(Node node)
Adds a child to the node.
|
void |
agregaElemento(int clase)
Adds an element of the class given to the node.
|
void |
calculaCoste(int fase)
Computes the cost of each node of the tree.
|
double |
calculaGini()
Computes and returns the Gini index for the node (continuous attributes).
|
double |
calculaGini(int indSubconjunto,
int[][] ocurrencias,
int numValores,
int numClases,
int totalOcurrencias)
Computes and returns the Gini index for the node (discrete attributes).
|
int |
costeError(Node hijo)
Computes the error cost of adding a child to the node.
|
void |
divide()
Divides the nodes into its two children.
|
boolean |
esHoja()
Checks if the node is a leaf.
|
Node[] |
getChildren()
Returns the children of the node.
|
Node |
getChildren(int index)
Returns the child with the given index.
|
int |
getClase()
Returns the class of the node.
|
int |
getCoste()
Returns the associated cost.
|
java.util.Vector<ListaAtributos>[] |
getData()
Returns the dataset that satisfies the node condition.
|
int |
getDecompositionAttribute()
Retuns the dataset that satisfies the node's condition.
|
double |
getDecompositionValue()
Returns the value used to divide the node.
|
double |
getIndiceGini()
Returns the the Gini index.
|
Node |
getParent()
Returns the father node.
|
int |
numChildren()
Returns the number of children.
|
void |
pruebaCorte(int indAtributo,
ListaClases[] listaClases,
Attribute atributo)
Checks a given cut and computes a possible improvement.
|
void |
pruebaCorte(int atributo,
ListaClases[] listaClases,
double valor,
double siguiente)
Checks a given cut and computes a possible improvement.
|
void |
setChildren(Node[] nodes)
Sets the children of the node.
|
void |
setCoste(int coste)
Sets the node cost with the value given.
|
void |
setData(java.util.Vector<ListaAtributos>[] newData)
Sets the dataset that satisfies the node's condition.
|
void |
setHoja(boolean b)
Sets the leaf contition.
|
void |
setParent(Node node)
Sets the father of the node with the given node.
|
public Node(int nClases)
nClases
- number of classes.public void agregaElemento(int clase)
clase
- given class.public void divide()
protected void actualizaHistograma(int clase)
clase
- class index from the element to be changed.public void actualizaClasePrincipal()
public void pruebaCorte(int indAtributo, ListaClases[] listaClases, Attribute atributo)
indAtributo
- attribute index.listaClases
- classes list.atributo
- attribute reference.public void pruebaCorte(int atributo, ListaClases[] listaClases, double valor, double siguiente)
atributo
- attribute index.listaClases
- classes list.valor
- cut value to check.siguiente
- next value.public double calculaGini()
public double calculaGini(int indSubconjunto, int[][] ocurrencias, int numValores, int numClases, int totalOcurrencias)
indSubconjunto
- subset index to check.ocurrencias
- occurrences matrix.numValores
- number of values in the matrix.numClases
- number of classes in the matrix.totalOcurrencias
- total number of occurrencespublic double getIndiceGini()
public void setData(java.util.Vector<ListaAtributos>[] newData)
newData
- Given dataset.public boolean esHoja()
public void setHoja(boolean b)
b
- true if the node is a leaf.public java.util.Vector<ListaAtributos>[] getData()
public int getClase()
public int getDecompositionAttribute()
public double getDecompositionValue()
public void setChildren(Node[] nodes)
nodes
- the children of the node.public void addChildren(Node node)
node
- given child.public int numChildren()
public Node[] getChildren()
public Node getChildren(int index)
index
- given child index.public void setParent(Node node)
node
- given father.public Node getParent()
public int getCoste()
public void calculaCoste(int fase)
fase
- Pruning phase identifier (1, first; 2, second).public int costeError(Node hijo)
hijo
- child node to add.public void setCoste(int coste)
coste
- given cost.