Class MultiCTBNC<NodeTypeBN extends Node,NodeTypeCTBN extends Node>

java.lang.Object
es.upm.fi.cig.multictbnc.models.AbstractPGM<Node>
es.upm.fi.cig.multictbnc.models.MultiCTBNC<NodeTypeBN,NodeTypeCTBN>
Type Parameters:
NodeTypeBN - type of the nodes of the BN (class subgraph)
NodeTypeCTBN - type of the nodes of the CTBN (feature subgraph)
All Implemented Interfaces:
Classifier, PGM<Node>
Direct Known Subclasses:
DAG_maxK_MultiCTBNC, Empty_digraph_MultiCTBNC, Empty_maxK_MultiCTBNC, MultiCTNBC

public class MultiCTBNC<NodeTypeBN extends Node,NodeTypeCTBN extends Node> extends AbstractPGM<Node> implements Classifier
Implements the multi-dimensional continuous-time Bayesian network classifier (Multi-CTBNC).
  • Constructor Details

    • MultiCTBNC

      public MultiCTBNC(BNLearningAlgorithms bnLearningAlgs, CTBNLearningAlgorithms ctbnLearningAlgs, Class<NodeTypeBN> bnNodeClass, Class<NodeTypeCTBN> ctbnNodeClass)
      Receives learning algorithms for Bayesian networks and continuous-time Bayesian networks to generate a Multi-CTBNC.
      Parameters:
      bnLearningAlgs - parameter and structure learning algorithms for Bayesian networks
      ctbnLearningAlgs - parameter and structure learning algorithms for continuous-time Bayesian networks
      bnNodeClass - Bayesian network node type
      ctbnNodeClass - continuous-time Bayesian network node type
    • MultiCTBNC

      public MultiCTBNC(BN<NodeTypeBN> bn, CTBN<NodeTypeCTBN> ctbn)
      Receives a Bayesian network and a continuous-time Bayesian network that represent the class subgraph and feature/bridge subgraph of a Multi-CTBNC, respectively.
      Parameters:
      bn - Bayesian network
      ctbn - continuous-time Bayesian network
  • Method Details

    • getNodesFeatureVariables

      public List<NodeTypeCTBN> getNodesFeatureVariables()
      Returns the list of nodes for the feature variables.
      Returns:
      list of nodes for the feature variables
    • getNodesClassVariables

      public List<NodeTypeBN> getNodesClassVariables()
      Returns the list of nodes for the class variables.
      Returns:
      list of nodes for the class variables
    • getInitialStructure

      public String getInitialStructure()
      Return the name of the initial structure of the model. This can be, for example, an empty structure (Empty) or a naive Bayes where all features are children of all class variables (Naive Bayes).
      Returns:
      name of the initial structure
    • setInitialStructure

      public void setInitialStructure(String initialStructure)
      Establishes the approach that will be used to define the initial structure of the Multi-CTBNC. For now, it is possible to define an empty structure or a naive Bayes.
      Parameters:
      initialStructure - initial structure that will be used (Empty (default) or naive Bayes)
    • getLearningAlgsBN

      public BNLearningAlgorithms getLearningAlgsBN()
      Returns learning algorithms for class subgraph (Bayesian network).
      Returns:
      learning algorithms for class subgraph (Bayesian network)
    • getLearningAlgsCTBN

      public CTBNLearningAlgorithms getLearningAlgsCTBN()
      Returns learning algorithms for bridge and features subgraphs (continuous time Bayesian network).
      Returns:
      learning algorithms for bridge and features subgraphs (continuous time Bayesian network)
    • getNameFeatureVariables

      public List<String> getNameFeatureVariables()
      Returns the names of the feature variables.
      Returns:
      names of the feature variables
    • getNumFeatureVariables

      public int getNumFeatureVariables()
      Returns the number of nodes for the feature variables.
      Returns:
      number of nodes for the feature variables
    • getTypeNodeClassVariable

      public Class<NodeTypeBN> getTypeNodeClassVariable()
      NodeFactory Returns the type of the class variable nodes.
      Returns:
      type of the class variable nodes
    • getTypeNodeFeature

      public Class<NodeTypeCTBN> getTypeNodeFeature()
      Returns the type of the feature nodes.
      Returns:
      type of the feature nodes
    • sample

      public Sequence sample(double duration)
      Samples a sequence given its duration.
      Parameters:
      duration - duration of the sequence
      Returns:
      sampled sequence
    • sample

      public Sequence sample(double duration, double percentageNoisyStates, double stdDeviationGaussianNoiseWaitingTime)
      Samples a sequence given its duration with added noise.
      Parameters:
      duration - duration of the sequence
      percentageNoisyStates - percentage of class variables' states and state transitions of feature variables which are randomly sampled.
      stdDeviationGaussianNoiseWaitingTime - standard deviation of the Gaussian distribution used to sample noise to be added to the waiting times of feature variables in a certain state
      Returns:
      sampled sequence
    • setBnLearningAlgs

      public void setBnLearningAlgs(BNLearningAlgorithms bnLearningAlgs)
      Sets the learning algorithms used to define the class subgraph (BN).
      Parameters:
      bnLearningAlgs - structure learning algorithms
    • setCtbnLearningAlgs

      public void setCtbnLearningAlgs(CTBNLearningAlgorithms ctbnLearningAlgs)
      Sets the learning algorithms used to define the bridge and feature subgraphs (CTBN).
      Parameters:
      ctbnLearningAlgs - structure learning algorithms
    • update

      public long update(List<Node> nodes, Dataset dataset) throws ErroneousValueException
      Learns the sets of parents and children of some nodes from a provided dataset and update the model with them.
      Parameters:
      nodes - list of nodes
      dataset - a dataset
      Returns:
      time to perform the learning
      Throws:
      ErroneousValueException - if an error occurs during the updating process
    • updateBridgeAndFeatureSubgraph

      public long updateBridgeAndFeatureSubgraph(Dataset dataset) throws ErroneousValueException
      Updates the bridge and feature subgraphs of the Multi-CTBNC model with new data from the provided dataset. If the model is empty, it learns the model for the first time using the dataset.
      Parameters:
      dataset - dataset containing the new data for updating the model
      Returns:
      time taken to update the model in milliseconds
      Throws:
      ErroneousValueException - if an error occurs during the updating process
    • getStructureConstraintsBN

      public StructureConstraints getStructureConstraintsBN()
      Returns the structure constraints for the BN.
      Returns:
      a StructureConstraint
    • getStructureConstraintsCTBN

      public StructureConstraints getStructureConstraintsCTBN()
      Returns the structure constraints for the CTBN.
      Returns:
      a StructureConstraint
    • areParametersEstimated

      public boolean areParametersEstimated()
      Description copied from interface: PGM
      Returns true if all the parameters were estimated.
      Specified by:
      areParametersEstimated in interface PGM<NodeTypeBN extends Node>
      Overrides:
      areParametersEstimated in class AbstractPGM<Node>
      Returns:
      true if all the parameters were estimated
    • getNodes

      public List<Node> getNodes()
      Description copied from interface: PGM
      Returns all the nodes in the model.
      Specified by:
      getNodes in interface PGM<NodeTypeBN extends Node>
      Overrides:
      getNodes in class AbstractPGM<Node>
      Returns:
      list of nodes
    • learn

      public long learn(Dataset dataset) throws ErroneousValueException
      Description copied from interface: PGM
      Learns the structure and parameters of the model from a given dataset.
      Specified by:
      learn in interface PGM<NodeTypeBN extends Node>
      Overrides:
      learn in class AbstractPGM<Node>
      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
    • learnParameters

      public void learnParameters(Dataset dataset)
      Description copied from interface: PGM
      Learns the parameters of the PGM using the provided dataset.
      Specified by:
      learnParameters in interface PGM<NodeTypeBN extends Node>
      Overrides:
      learnParameters in class AbstractPGM<Node>
      Parameters:
      dataset - dataset used to learn the parameters
    • getBN

      public BN<NodeTypeBN> getBN()
      Returns the Bayesian network used to model the class subgraph of the Multi-CTBNC.
      Returns:
      a Bayesian network
    • getCTBN

      public CTBN<NodeTypeCTBN> getCTBN()
      Returns the continuous-time Bayesian network used to model the bridge and feature subgraphs of the Multi-CTBNC.
      Returns:
      a continuous-time Bayesian network
    • getNodesCTBN

      public List<NodeTypeCTBN> getNodesCTBN()
      Returns the nodes of the continuous-time Bayesian network modelling the feature and bridge subgraphs of the Multi-CTBNC.
      Returns:
      node list
    • learnParameters

      public void learnParameters(Dataset dataset, int idxNode)
      Description copied from interface: PGM
      Learns the parameters of a certain node of the PGM using the provided dataset.
      Specified by:
      learnParameters in interface PGM<NodeTypeBN extends Node>
      Overrides:
      learnParameters in class AbstractPGM<Node>
      Parameters:
      dataset - dataset used to learn the parameters
      idxNode - node index
    • getModelIdentifier

      public String getModelIdentifier()
      Description copied from interface: PGM
      Returns a String that identifies the model.
      Specified by:
      getModelIdentifier in interface PGM<NodeTypeBN extends Node>
      Returns:
      String that identifies the model
    • getType

      public String getType()
      Description copied from interface: PGM
      Provides the type of PGM.
      Specified by:
      getType in interface PGM<NodeTypeBN extends Node>
      Returns:
      string describing the type of PGM
    • predict

      public Prediction[] predict(Dataset dataset, boolean estimateProbabilities)
      Performs classification over the sequences of a dataset according to the maximum a posteriori probability, i.e., the classes that obtain the highest posterior probability given each sequence are predicted.
      Specified by:
      predict in interface Classifier
      Parameters:
      dataset - dataset from which the sequences to predict are extracted
      estimateProbabilities - true to estimate the probabilities of the class configurations, false otherwise
      Returns:
      array of Prediction objects (one per sequence) that contain the predicted classes and, if requested, the probabilities of all possible class configurations
    • getNodesCTBNInMarkovBlanketClassVariables

      public List<NodeTypeCTBN> getNodesCTBNInMarkovBlanketClassVariables()
      Returns the nodes of the continuous-time Bayesian network modelling the feature and bridge subgraphs of the Multi-CTBNC, which are in the Markov blaket of at least one class variable.
      Returns:
      node list
    • toString

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

      public int getNumClassVariables()
      Returns the number of nodes for the class variables.
      Returns:
      number of nodes for the class variables