Class BN<NodeType extends Node>

java.lang.Object
es.upm.fi.cig.multictbnc.models.AbstractPGM<NodeType>
es.upm.fi.cig.multictbnc.models.BN<NodeType>
Type Parameters:
NodeType - type of the nodes of the BN, e.g., nodes with conditional probability table (CPTNode)
All Implemented Interfaces:
PGM<NodeType>

public class BN<NodeType extends Node> extends AbstractPGM<NodeType>
Implements a Bayesian network (BN).
  • Constructor Details

    • BN

      public BN(List<NodeType> nodes)
      Initialises a Bayesian network by receiving a list of nodes.
      Parameters:
      nodes - list of nodes
    • BN

      public BN(List<NodeType> nodes, Dataset dataset)
      Initialises a Bayesian network by receiving a list of nodes and a dataset. This constructor was thought to be used by MultiCTBNC.
      Parameters:
      nodes - list of nodes
      dataset - dataset used to learn the Bayesian network
    • BN

      public BN(Dataset dataset, List<String> nameVariables, BNLearningAlgorithms bnLearningAlgs, StructureConstraints structureConstraints, Class<NodeType> nodeClass)
      Initialises a Bayesian network by receiving a dataset, a list of variables to use and the algorithms for parameter and structure learning. This constructor was thought to be used by MultiCTBNC.
      Parameters:
      dataset - dataset used to learn the Bayesian network
      nameVariables - name of the variables
      bnLearningAlgs - parameter and structure learning algorithms
      structureConstraints - structure constrains to take into account during the learning of the Bayesian network
      nodeClass - type of the BN nodes
    • BN

      public BN(BN<NodeType> bn, boolean cloneStructure)
      Constructor to clone a Bayesian network.
      Parameters:
      bn - Bayesian network to clone
      cloneStructure - true if the structure of the BN should be clone, false to define the model nodes from a dataset contained in the BN, if any, without copying the structure.
  • Method Details

    • getLearntNodes

      public List<NodeType> getLearntNodes()
      Returns the nodes with the learnt parameters. This can be, for example, a list of CPTNode objects that store conditional probability tables.
      Returns:
      nodes with learnt parameters
    • getTopologicalOrdering

      public List<Node> getTopologicalOrdering()
      Obtains the topological ordering of the nodes with the Kahn's algorithm.
      Returns:
      sorted nodes
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getType

      public String getType()
      Description copied from interface: PGM
      Provides the type of PGM.
      Returns:
      string describing the type of PGM
    • getModelIdentifier

      public String getModelIdentifier()
      Description copied from interface: PGM
      Returns a String that identifies the model.
      Returns:
      String that identifies the model