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 Details

    • addNodes

      void addNodes(List<NodeType> nodes, boolean createNodes)
      Adds the provided nodes to the PGM.
      Parameters:
      nodes - nodes to add
      createNodes - 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

      void computeSufficientStatistics(List<Integer> idxNodes)
      Computes the sufficient statistics for the nodes whose indexes are specified.
      Parameters:
      idxNodes - node indexes
    • display

      void display()
      Displays the probabilistic graphical model.
    • display

      void display(String windowTitle)
      Displays the probabilistic graphical model.
      Parameters:
      windowTitle - title of the window where the model is displayed
    • display

      void display(String title, List<Integer> nodesToHighlight)
      Displays the probabilistic graphical model.
      Parameters:
      title - title of the window where the model is displayed
      nodesToHighlight - 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

      List<Integer> getIndexNodes()
      Returns the indexes of the nodes.
      Returns:
      node indexes
    • getModelIdentifier

      String getModelIdentifier()
      Returns a String that identifies the model.
      Returns:
      String that identifies the model
    • getNamesNodesByIndex

      List<String> getNamesNodesByIndex(List<Integer> idxNodes)
      Return the names of the nodes whose indexes are given.
      Parameters:
      idxNodes - node indexes
      Returns:
      node names
    • getNodeByIndex

      NodeType getNodeByIndex(int idxNode)
      Obtains the node (feature or class variable) with a certain index.
      Parameters:
      idxNode - node index
      Returns:
      node with the specified index
    • getIndexOfNode

      int getIndexOfNode(Node node)
      Returns the index of the provided node.
      Parameters:
      node - node for which the index is needed
      Returns:
      index of the node
    • getNodeByName

      NodeType getNodeByName(String nameVariable)
      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

      List<NodeType> 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

      void initialiseModel(Dataset dataset)
      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-dimensional boolean array representing the adjacency matrix to analyse
      Returns:
      true if the structure is legal, false otherwise
    • learn

      void learn() throws ErroneousValueException
      Learns the structure and parameters of the model.
      Throws:
      ErroneousValueException - if a provided parameter is erroneous for the requested task
    • learn

      long learn(Dataset dataset) throws ErroneousValueException
      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

      void learn(Dataset dataset, int idxNode) throws ErroneousValueException
      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 node
      idxNode - node index
      Throws:
      ErroneousValueException - if a provided parameter is erroneous for the requested task
    • learn

      void learn(Dataset dataset, List<Integer> idxNodes) throws ErroneousValueException
      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 nodes
      idxNodes - node indexes
      Throws:
      ErroneousValueException - if a provided parameter is erroneous for the requested task
    • learnParameters

      void learnParameters()
      Learns the parameters of the PGM.
    • learnParameters

      void learnParameters(Dataset dataset)
      Learns the parameters of the PGM using the provided dataset.
      Parameters:
      dataset - dataset used to learn the parameters
    • learnParameters

      void learnParameters(Dataset dataset, int idxNode)
      Learns the parameters of a certain node of the PGM using the provided dataset.
      Parameters:
      dataset - dataset used to learn the parameters
      idxNode - node index
    • learnParameters

      void learnParameters(List<Integer> idxNodes)
      Learns the parameters of the nodes whose indexes are specified.
      Parameters:
      idxNodes - indexes of the nodes whose parameters should be learnt
    • learnParameters

      void learnParameters(Integer idxNode)
      Learns the parameters of the node whose index is specified.
      Parameters:
      idxNode - index of the node whose parameters should be learnt
    • learnParameters

      void learnParameters(List<Integer> idxNodes, ParameterLearningAlgorithm parameterLearningAlg)
      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 learnt
      parameterLearningAlg - a ParameterLearningAlgorithm
    • removeAllEdges

      void removeAllEdges()
      Remove all edges between the nodes of the PGM.
    • removeAllNodes

      void removeAllNodes()
      Removes all the nodes from the PGM.
    • saveGraph

      void saveGraph(String filePath, String filename, List<Integer> idxNodesToHighlight)
      Saves the PGM graph to a file.
      Parameters:
      filePath - destination path of the file
      filename - filename
      idxNodesToHighlight - 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 index
      structureFound - adjacency matrix
    • setStructure

      void setStructure(List<Integer> idxNodes, boolean[][] structureFound)
      Updates the structure of the model only for the specified node.
      Parameters:
      idxNodes - node indexes
      structureFound - 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