java.lang.Object
es.upm.fi.cig.multictbnc.nodes.AbstractNode
es.upm.fi.cig.multictbnc.nodes.DiscreteStateNode
- All Implemented Interfaces:
Node
Abstract class defining common variables and methods for discrete nodes.
-
Constructor Summary
ConstructorDescriptionDiscreteStateNode
(String name, List<String> states) Initialises a discrete node given a list of states.DiscreteStateNode
(String name, List<String> states, boolean isClassVariable) Initialises a discrete node specifying if the node is for a class variable or a feature. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Remove the set of parents and children of the node.int
Gets the index of the current state of the node.int
Gets the index for the current state of the node's parents.int
getIdxStateParents
(List<String> nameParents) Gets the index for the current state of the specified parents of the node.int
Returns the number of possible states of the node.int
Returns the number of possible states of the parents of the node.getState()
Gets the state of the node.Returns a list of the states that the node can take.void
removeParent
(Node nodeParent) Removes a certain parent of the node.void
Defines a provided node as a parent of this one.void
setState
(int stateIdx) Sets the state index of the node.Sets the state of the node and returns its id.void
setStateParents
(int idxStateParents) Sets the states of the parents of the node given the index related to their state.toString()
Methods inherited from class es.upm.fi.cig.multictbnc.nodes.AbstractNode
equals, getChildren, getName, getNumParents, getParents, hasChildren, hasClassVariableAsParent, hasClassVariableAsSpouse, hashCode, hasParents, isClassVariable, isClassVariable, isDisconnected, isInMarkovBlanketClassVariable, removeAllEdges, removeChild, removeChildren, removeParents, setChild
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface es.upm.fi.cig.multictbnc.nodes.Node
areParametersEstimated, estimateLogLikelihood, setSufficientStatistics
-
Constructor Details
-
DiscreteStateNode
Initialises a discrete node given a list of states.- Parameters:
name
- name of the nodestates
- list of strings representing the states that the variable related to the node can take
-
DiscreteStateNode
Initialises a discrete node specifying if the node is for a class variable or a feature.- Parameters:
name
- name of the nodestates
- list of strings representing the states that the variable related to the node can takeisClassVariable
- true if the node represent a class variable, false otherwise
-
-
Method Details
-
getIdxState
public int getIdxState()Gets the index of the current state of the node.- Returns:
- index of the current state of the node
-
getIdxStateParents
public int getIdxStateParents()Gets the index for the current state of the node's parents. Return -1 if the state of one parent was not seen during training. Algorithm from https://github.com/dcodecasa/CTBNCToolkit.- Returns:
- index for the current state of the node's parents
-
getIdxStateParents
Gets the index for the current state of the specified parents of the node. Returns -1 if the state of one parent was not seen during training or if the parent does not exist. Returns 0 if the provided parent list is null or empty.- Parameters:
nameParents
- name of the parent nodes- Returns:
- index for the current state of the specified subset of parents
-
getNumStates
public int getNumStates()Returns the number of possible states of the node.- Returns:
- number of states of the node
-
getNumStatesParents
public int getNumStatesParents()Returns the number of possible states of the parents of the node.- Returns:
- number of states of the node's parents
-
getState
Gets the state of the node.- Returns:
- state of the node
-
setState
public void setState(int stateIdx) Sets the state index of the node. The state index is not changed if the provided index was not seen during training.- Parameters:
stateIdx
- node state index
-
getStates
Returns a list of the states that the node can take.- Returns:
- list of strings representing the states that the variable related to the node can take
-
setState
Sets the state of the node and returns its id. If the state was not seen during training, -1 is returned.- Parameters:
state
- state of the node- Returns:
- id of the state
-
setStateParents
public void setStateParents(int idxStateParents) Sets the states of the parents of the node given the index related to their state. Algorithm from https://github.com/dcodecasa/CTBNCToolkit.- Parameters:
idxStateParents
- index of the state of the node's parents
-
clearParentAndChildrenSets
public void clearParentAndChildrenSets()Description copied from interface:Node
Remove the set of parents and children of the node. This method should be used with caution, as references to this node from others will not be affected. It is recommended its use when creating an empty PGM, i.e., we are removing all edges between nodes.- Specified by:
clearParentAndChildrenSets
in interfaceNode
- Overrides:
clearParentAndChildrenSets
in classAbstractNode
-
removeParent
Description copied from interface:Node
Removes a certain parent of the node.- Specified by:
removeParent
in interfaceNode
- Overrides:
removeParent
in classAbstractNode
- Parameters:
nodeParent
- parent node
-
setParent
Description copied from interface:Node
Defines a provided node as a parent of this one.- Specified by:
setParent
in interfaceNode
- Overrides:
setParent
in classAbstractNode
- Parameters:
nodeParent
- parent node
-
toString
- Overrides:
toString
in classAbstractNode
-