Module es.upm.fi.cig.multictbnc
Package es.upm.fi.cig.multictbnc.models
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 Summary
ConstructorDescriptionMultiCTBNC
(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.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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if all the parameters were estimated.getBN()
Returns the Bayesian network used to model the class subgraph of the Multi-CTBNC.getCTBN()
Returns the continuous-time Bayesian network used to model the bridge and feature subgraphs of the Multi-CTBNC.Return the name of the initial structure of the model.Returns learning algorithms for class subgraph (Bayesian network).Returns learning algorithms for bridge and features subgraphs (continuous time Bayesian network).Returns aString
that identifies the model.Returns the names of the feature variables.getNodes()
Returns all the nodes in the model.Returns the list of nodes for the class variables.Returns the nodes of the continuous-time Bayesian network modelling the feature and bridge subgraphs of the Multi-CTBNC.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 the list of nodes for the feature variables.int
Returns the number of nodes for the class variables.int
Returns the number of nodes for the feature variables.Returns the structure constraints for the BN.Returns the structure constraints for the CTBN.getType()
Provides the type of PGM.NodeFactory Returns the type of the class variable nodes.Returns the type of the feature nodes.long
Learns the structure and parameters of the model from a given dataset.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.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.sample
(double duration) Samples a sequence given its duration.sample
(double duration, double percentageNoisyStates, double stdDeviationGaussianNoiseWaitingTime) Samples a sequence given its duration with added noise.void
setBnLearningAlgs
(BNLearningAlgorithms bnLearningAlgs) Sets the learning algorithms used to define the class subgraph (BN).void
setCtbnLearningAlgs
(CTBNLearningAlgorithms ctbnLearningAlgs) Sets the learning algorithms used to define the bridge and feature subgraphs (CTBN).void
setInitialStructure
(String initialStructure) Establishes the approach that will be used to define the initial structure of the Multi-CTBNC.toString()
long
Learns the sets of parents and children of some nodes from a provided dataset and update the model with them.long
updateBridgeAndFeatureSubgraph
(Dataset dataset) Updates the bridge and feature subgraphs of the Multi-CTBNC model with new data from the provided dataset.Methods inherited from class es.upm.fi.cig.multictbnc.models.AbstractPGM
addNodes, computeSufficientStatistics, display, display, display, getAdjacencyMatrix, getDataset, getHyperparameters, getIndexNodes, getIndexOfNode, getNamesNodesByIndex, getNameVariables, getNodeByIndex, getNodeByName, getNodeClass, getNodeFactory, getNodeIndexer, getNumNodes, getParameterLearningAlg, getStructureConstraints, getStructureLearningAlg, initialiseModel, isStructureLegal, learn, learn, learn, learnParameters, learnParameters, learnParameters, learnParameters, removeAllEdges, removeAllNodes, saveGraph, setDataset, setNameVariables, setParameterLearningAlgorithm, setStructure, setStructure, setStructure, setStructureConstraints, setStructureLearningAlgorithm, setStructureModifiedNodes
-
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 networksctbnLearningAlgs
- parameter and structure learning algorithms for continuous-time Bayesian networksbnNodeClass
- Bayesian network node typectbnNodeClass
- continuous-time Bayesian network node type
-
MultiCTBNC
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 networkctbn
- continuous-time Bayesian network
-
-
Method Details
-
getNodesFeatureVariables
Returns the list of nodes for the feature variables.- Returns:
- list of nodes for the feature variables
-
getNodesClassVariables
Returns the list of nodes for the class variables.- Returns:
- list of nodes for the class variables
-
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
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
Returns learning algorithms for class subgraph (Bayesian network).- Returns:
- learning algorithms for class subgraph (Bayesian network)
-
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
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
NodeFactory Returns the type of the class variable nodes.- Returns:
- type of the class variable nodes
-
getTypeNodeFeature
Returns the type of the feature nodes.- Returns:
- type of the feature nodes
-
sample
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 sequencepercentageNoisyStates
- 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
Sets the learning algorithms used to define the class subgraph (BN).- Parameters:
bnLearningAlgs
- structure learning algorithms
-
setCtbnLearningAlgs
Sets the learning algorithms used to define the bridge and feature subgraphs (CTBN).- Parameters:
ctbnLearningAlgs
- structure learning algorithms
-
update
Learns the sets of parents and children of some nodes from a provided dataset and update the model with them.- Parameters:
nodes
- list of nodesdataset
- a dataset- Returns:
- time to perform the learning
- Throws:
ErroneousValueException
- if an error occurs during the updating process
-
updateBridgeAndFeatureSubgraph
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
Returns the structure constraints for the BN.- Returns:
- a
StructureConstraint
-
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 interfacePGM<NodeTypeBN extends Node>
- Overrides:
areParametersEstimated
in classAbstractPGM<Node>
- Returns:
- true if all the parameters were estimated
-
getNodes
Description copied from interface:PGM
Returns all the nodes in the model.- Specified by:
getNodes
in interfacePGM<NodeTypeBN extends Node>
- Overrides:
getNodes
in classAbstractPGM<Node>
- Returns:
- list of nodes
-
learn
Description copied from interface:PGM
Learns the structure and parameters of the model from a given dataset.- Specified by:
learn
in interfacePGM<NodeTypeBN extends Node>
- Overrides:
learn
in classAbstractPGM<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
Description copied from interface:PGM
Learns the parameters of the PGM using the provided dataset.- Specified by:
learnParameters
in interfacePGM<NodeTypeBN extends Node>
- Overrides:
learnParameters
in classAbstractPGM<Node>
- Parameters:
dataset
- dataset used to learn the parameters
-
getBN
Returns the Bayesian network used to model the class subgraph of the Multi-CTBNC.- Returns:
- a Bayesian network
-
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
Returns the nodes of the continuous-time Bayesian network modelling the feature and bridge subgraphs of the Multi-CTBNC.- Returns:
- node list
-
learnParameters
Description copied from interface:PGM
Learns the parameters of a certain node of the PGM using the provided dataset.- Specified by:
learnParameters
in interfacePGM<NodeTypeBN extends Node>
- Overrides:
learnParameters
in classAbstractPGM<Node>
- Parameters:
dataset
- dataset used to learn the parametersidxNode
- node index
-
getModelIdentifier
Description copied from interface:PGM
Returns aString
that identifies the model.- Specified by:
getModelIdentifier
in interfacePGM<NodeTypeBN extends Node>
- Returns:
String
that identifies the model
-
getType
Description copied from interface:PGM
Provides the type of PGM.- Specified by:
getType
in interfacePGM<NodeTypeBN extends Node>
- Returns:
- string describing the type of PGM
-
predict
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 interfaceClassifier
- Parameters:
dataset
- dataset from which the sequences to predict are extractedestimateProbabilities
- 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
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
-
getNumClassVariables
public int getNumClassVariables()Returns the number of nodes for the class variables.- Returns:
- number of nodes for the class variables
-