Module es.upm.fi.cig.multictbnc
Package es.upm.fi.cig.multictbnc.models
Interface PGM<NodeType extends Node>
- Type Parameters:
NodeType
- type of the nodes of the PGM
- All Known Implementing Classes:
AbstractPGM
,BN
,CTBN
,DAG_maxK_MultiCTBNC
,Empty_digraph_MultiCTBNC
,Empty_maxK_MultiCTBNC
,MultiCTBNC
,MultiCTNBC
public interface PGM<NodeType extends Node>
Defines the methods of a probabilistic graphical model (PGM)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the provided nodes to the PGM.boolean
Returns true if all the parameters were estimated.void
computeSufficientStatistics
(List<Integer> idxNodes) Computes the sufficient statistics for the nodes whose indexes are specified.void
display()
Displays the probabilistic graphical model.void
Displays the probabilistic graphical model.void
Displays the probabilistic graphical model.boolean[][]
Returns the adjacency matrix.Returns the indexes of the nodes.int
getIndexOfNode
(Node node) Returns the index of the provided node.Returns aString
that identifies the model.getNamesNodesByIndex
(List<Integer> idxNodes) Return the names of the nodes whose indexes are given.getNodeByIndex
(int idxNode) Obtains the node (feature or class variable) with a certain index.getNodeByName
(String nameVariable) Returns the node whose variable name is given.Returns the node indexer used by the PGM.getNodes()
Returns all the nodes in the model.int
Returns the number of nodes.Returns the algorithm that is used to learn the parameters of the PGM.getType()
Provides the type of PGM.void
initialiseModel
(Dataset dataset) Sets the dataset that will be used to estimate the structure and parameters of the model and creates its nodes.boolean
isStructureLegal
(boolean[][] adjacencyMatrix) Checks if a structure is legal for the PGM.void
learn()
Learns the structure and parameters of the model.long
Learns the structure and parameters of the model from a given dataset.void
Learns the parameters and parent set of a model's node from a given dataset.void
Learns the parameters and parent set of some nodes of the model from a given dataset.void
Learns the parameters of the PGM.void
learnParameters
(Dataset dataset) Learns the parameters of the PGM using the provided dataset.void
learnParameters
(Dataset dataset, int idxNode) Learns the parameters of a certain node of the PGM using the provided dataset.void
learnParameters
(Integer idxNode) Learns the parameters of the node whose index is specified.void
learnParameters
(List<Integer> idxNodes) Learns the parameters of the nodes whose indexes are specified.void
learnParameters
(List<Integer> idxNodes, ParameterLearningAlgorithm parameterLearningAlg) Learns the parameters of the nodes whose indexes are specified using a provider parameter learning algorithm.void
Remove all edges between the nodes of the PGM.void
Removes all the nodes from the PGM.void
Saves the PGM graph to a file.void
setStructure
(boolean[][] newAdjacencyMatrix) Modifies the structure of the PGM by changing the parents of the nodes.void
setStructure
(int idxNode, boolean[][] structureFound) Updates the structure of the model only for the specified node.void
setStructure
(List<Integer> idxNodes, boolean[][] structureFound) Updates the structure of the model only for the specified node.void
setStructureModifiedNodes
(boolean[][] newAdjacencyMatrix) Modifies the structure of the PGM by changing the parents and CPDs of those nodes which have different parents between the current adjacency matrix and the new one.
-
Method Details
-
addNodes
Adds the provided nodes to the PGM.- Parameters:
nodes
- nodes to addcreateNodes
-true
to create new nodes from the provided ones,false
otherwise (any change to the provided nodes will affect this model).
-
areParametersEstimated
boolean areParametersEstimated()Returns true if all the parameters were estimated.- Returns:
- true if all the parameters were estimated
-
computeSufficientStatistics
Computes the sufficient statistics for the nodes whose indexes are specified.- Parameters:
idxNodes
- node indexes
-
display
void display()Displays the probabilistic graphical model. -
display
Displays the probabilistic graphical model.- Parameters:
windowTitle
- title of the window where the model is displayed
-
display
Displays the probabilistic graphical model.- Parameters:
title
- title of the window where the model is displayednodesToHighlight
- indexes of the nodes to be highlighted in red
-
getAdjacencyMatrix
boolean[][] getAdjacencyMatrix()Returns the adjacency matrix.- Returns:
- two-dimensional
boolean
array representing the adjacency matrix
-
getIndexNodes
Returns the indexes of the nodes.- Returns:
- node indexes
-
getModelIdentifier
String getModelIdentifier()Returns aString
that identifies the model.- Returns:
String
that identifies the model
-
getNamesNodesByIndex
Return the names of the nodes whose indexes are given.- Parameters:
idxNodes
- node indexes- Returns:
- node names
-
getNodeByIndex
Obtains the node (feature or class variable) with a certain index.- Parameters:
idxNode
- node index- Returns:
- node with the specified index
-
getIndexOfNode
Returns the index of the provided node.- Parameters:
node
- node for which the index is needed- Returns:
- index of the node
-
getNodeByName
Returns the node whose variable name is given.- Parameters:
nameVariable
- name of the variable- Returns:
- requested node
-
getNodeIndexer
NodeIndexer<NodeType> getNodeIndexer()Returns the node indexer used by the PGM.- Returns:
- node indexer
-
getNodes
Returns all the nodes in the model.- Returns:
- list of nodes
-
getNumNodes
int getNumNodes()Returns the number of nodes.- Returns:
- number of nodes
-
getParameterLearningAlg
ParameterLearningAlgorithm getParameterLearningAlg()Returns the algorithm that is used to learn the parameters of the PGM.- Returns:
- parameter learning algorithm
-
getType
String getType()Provides the type of PGM.- Returns:
- string describing the type of PGM
-
initialiseModel
Sets the dataset that will be used to estimate the structure and parameters of the model and creates its nodes.- Parameters:
dataset
- dataset used to learn the model
-
isStructureLegal
boolean isStructureLegal(boolean[][] adjacencyMatrix) Checks if a structure is legal for the PGM.- Parameters:
adjacencyMatrix
- two-dimensionalboolean
array representing the adjacency matrix to analyse- Returns:
- true if the structure is legal, false otherwise
-
learn
Learns the structure and parameters of the model.- Throws:
ErroneousValueException
- if a provided parameter is erroneous for the requested task
-
learn
Learns the structure and parameters of the model from a given dataset.- Parameters:
dataset
- dataset used to learn the model- Returns:
- time to learn the model
- Throws:
ErroneousValueException
- if a provided parameter is erroneous for the requested task
-
learn
Learns the parameters and parent set of a model's node from a given dataset.- Parameters:
dataset
- dataset used to learn the parameters and parent set of the nodeidxNode
- node index- Throws:
ErroneousValueException
- if a provided parameter is erroneous for the requested task
-
learn
Learns the parameters and parent set of some nodes of the model from a given dataset.- Parameters:
dataset
- dataset used to learn the parameters and parent set of the nodesidxNodes
- node indexes- Throws:
ErroneousValueException
- if a provided parameter is erroneous for the requested task
-
learnParameters
void learnParameters()Learns the parameters of the PGM. -
learnParameters
Learns the parameters of the PGM using the provided dataset.- Parameters:
dataset
- dataset used to learn the parameters
-
learnParameters
Learns the parameters of a certain node of the PGM using the provided dataset.- Parameters:
dataset
- dataset used to learn the parametersidxNode
- node index
-
learnParameters
Learns the parameters of the nodes whose indexes are specified.- Parameters:
idxNodes
- indexes of the nodes whose parameters should be learnt
-
learnParameters
Learns the parameters of the node whose index is specified.- Parameters:
idxNode
- index of the node whose parameters should be learnt
-
learnParameters
Learns the parameters of the nodes whose indexes are specified using a provider parameter learning algorithm.- Parameters:
idxNodes
- indexes of the nodes whose parameters should be learntparameterLearningAlg
- aParameterLearningAlgorithm
-
removeAllEdges
void removeAllEdges()Remove all edges between the nodes of the PGM. -
removeAllNodes
void removeAllNodes()Removes all the nodes from the PGM. -
saveGraph
Saves the PGM graph to a file.- Parameters:
filePath
- destination path of the filefilename
- filenameidxNodesToHighlight
- indexes of the nodes to highlight
-
setStructure
void setStructure(boolean[][] newAdjacencyMatrix) Modifies the structure of the PGM by changing the parents of the nodes.- Parameters:
newAdjacencyMatrix
- adjacency matrix with the new structure of the PGM
-
setStructure
void setStructure(int idxNode, boolean[][] structureFound) Updates the structure of the model only for the specified node.- Parameters:
idxNode
- node indexstructureFound
- adjacency matrix
-
setStructure
Updates the structure of the model only for the specified node.- Parameters:
idxNodes
- node indexesstructureFound
- adjacency matrix found
-
setStructureModifiedNodes
void setStructureModifiedNodes(boolean[][] newAdjacencyMatrix) Modifies the structure of the PGM by changing the parents and CPDs of those nodes which have different parents between the current adjacency matrix and the new one.- Parameters:
newAdjacencyMatrix
- new adjacency matrix
-