Bayesian Networks¶
The pybnesian.models module includes many different types of Bayesian networks.
Abstract Classes¶
This classes are abstract and define the interface for Bayesian network objects. The BayesianNetworkType
specifies the type of Bayesian networks.
Each BayesianNetworkType
can be used in many multiple variants
of Bayesian networks: BayesianNetworkBase
(a normal Bayesian network), ConditionalBayesianNetworkBase
(a conditional Bayesian network) and DynamicBayesianNetworkBase
(a dynamic Bayesian network).
- class pybnesian.models.BayesianNetworkType¶
A representation of a
BayesianNetwork
that defines its behaviour.- __init__(self: pybnesian.models.BayesianNetworkType) → None¶
Initializes a new
BayesianNetworkType
- __str__(self: pybnesian.models.BayesianNetworkType) → str¶
- alternative_node_type(model: BayesianNetworkBase or ConditionalBayesianNetworkBase, source: str) → List[pybnesian.factors.FactorType]¶
Returns all feasible alternative
FactorType
fornode
.- Parameters
model – BayesianNetwork model.
node – Name of the node.
- Returns
A list of alternative
FactorType
. If you implement this method in a Python-derived class, you can return an empty list or None to specify that no changes are possible.
- can_have_arc(model: BayesianNetworkBase or ConditionalBayesianNetworkBase, source: str, target: str) → bool¶
Checks whether the
BayesianNetworkType
allows an arcsource
->target
in the Bayesian networkmodel
.- Parameters
model – BayesianNetwork model.
source – Name of the source node.
target – Name of the target node.
- Returns
True if the arc
source
->target
is allowed inmodel
, False otherwise.
- compatible_node_type(model: BayesianNetworkBase or ConditionalBayesianNetworkBase, node: str, node_type: pybnesian.factors.FactorType) → bool¶
Checks whether the
FactorType
node_type
is allowed fornode
by thisBayesianNetworkType
.- Parameters
model – BayesianNetwork model.
node – Name of the node to check.
node_type –
FactorType
fornode
.
- Returns
True if the current
FactorType
is allowed, False otherwise.
- data_default_node_type(self: pybnesian.models.BayesianNetworkType, datatype: pyarrow.DataType) → pybnesian.factors.FactorType¶
Returns the default
FactorType
of the nodes of this Bayesian network type with data typedatatype
. This method is only needed for non-homogeneous Bayesian networks and defines the defaultFactorType
for the givendatatype
.- Parameters
datatype –
pyarrow.DataType
defining the type of data for a node.- Returns
default
FactorType
for a node given thedatatype
.
- default_node_type(self: pybnesian.models.BayesianNetworkType) → pybnesian.factors.FactorType¶
Returns the default
FactorType
of each node in this Bayesian network type. This method is only needed for homogeneous Bayesian networks and returns the unique possibleFactorType
.- Returns
default
FactorType
for the nodes.
- is_homogeneous(self: pybnesian.models.BayesianNetworkType) → bool¶
Checks whether the Bayesian network is homogeneous.
A Bayesian network is homogeneous if the
FactorType
of all the nodes are forced to be the same: for example, a Gaussian network is homogeneous because theFactorType
type of each node is alwaysLinearGaussianCPDType
.- Returns
True if the Bayesian network is homogeneous, False otherwise.
- new_bn(self: pybnesian.models.BayesianNetworkType, nodes: List[str]) → pybnesian.models.BayesianNetworkBase¶
Returns an empty unconditional Bayesian network of this type with the given
nodes
.- Parameters
nodes – Nodes of the new Bayesian network.
- Returns
A new empty unconditional Bayesian network.
- new_cbn(self: pybnesian.models.BayesianNetworkType, nodes: List[str], interface_nodes: List[str]) → pybnesian.models.ConditionalBayesianNetworkBase¶
Returns an empty conditional Bayesian network of this type with the given
nodes
andinterface_nodes
.- Parameters
nodes – Nodes of the new Bayesian network.
nodes – Interface nodes of the new Bayesian network.
- Returns
A new empty conditional Bayesian network.
- class pybnesian.models.BayesianNetworkBase¶
This class defines an interface of base operations for all the Bayesian networks.
It reproduces many of the methods in the underlying graph to perform additional initializations and simplify the access. See Graph Module.
- __str__(self: pybnesian.models.BayesianNetworkBase) → str¶
- add_arc(self: pybnesian.models.BayesianNetworkBase, source: str, target: str) → None¶
Adds an arc between the nodes
source
andtarget
. If the arc already exists, the graph is left unaffected.- Parameters
source – A node name.
target – A node name.
- add_cpds(self: pybnesian.models.BayesianNetworkBase, cpds: List[pybnesian.factors.Factor]) → None¶
Adds a list of CPDs to the Bayesian network. The list may be complete (for all the nodes all the Bayesian network) or partial (just some a subset of the nodes).
- Parameters
cpds – List of
Factor
.
- add_node(self: pybnesian.models.BayesianNetworkBase, node: str) → int¶
Adds a node to the Bayesian network and returns its index.
- Parameters
node – Name of the new node.
- Returns
Index of the new node.
- arcs(self: pybnesian.models.BayesianNetworkBase) → List[Tuple[str, str]]¶
Gets the list of arcs.
- Returns
A list of tuples (source, target) representing an arc source -> target.
- can_add_arc(self: pybnesian.models.BayesianNetworkBase, source: str, target: str) → bool¶
Checks whether an arc between the nodes
source
andtarget
can be added.An arc addition can be not allowed for multiple reasons:
It generates a cycle.
It is a conditional BN and both source and target are interface nodes.
It is not allowed by the
BayesianNetworkType
.
- Parameters
source – A node name.
target – A node name.
- Returns
True if the arc can be added, False otherwise.
- can_flip_arc(self: pybnesian.models.BayesianNetworkBase, source: str, target: str) → bool¶
Checks whether an arc between the nodes
source
andtarget
can be flipped.An arc flip can be not allowed for multiple reasons:
It generates a cycle.
It is not allowed by the
BayesianNetworkType
.
- Parameters
source – A node name.
target – A node name.
- Returns
True if the arc can be added, False otherwise.
- children(self: pybnesian.models.BayesianNetworkBase, node: str) → List[str]¶
Gets the children nodes of a node.
- Parameters
node – A node name.
- Returns
Children node names.
- clone(self: pybnesian.models.BayesianNetworkBase) → pybnesian.models.BayesianNetworkBase¶
Clones (copies) this Bayesian network.
- Returns
A copy of
self
.
- collapsed_from_index(self: pybnesian.models.BayesianNetworkBase, index: int) → int¶
Gets the collapsed index of a node from its index.
- Parameters
index – Index of the node.
- Returns
Collapsed index of the node.
- collapsed_index(self: pybnesian.models.BayesianNetworkBase, node: str) → int¶
Gets the collapsed index of a node from its name.
- Parameters
node – Name of the node.
- Returns
Collapsed index of the node.
- collapsed_indices(self: pybnesian.models.BayesianNetworkBase) → Dict[str, int]¶
Gets all the collapsed indices for the nodes in the graph.
- Returns
A dictionary with the collapsed index of each node.
- collapsed_name(self: pybnesian.models.BayesianNetworkBase, collapsed_index: int) → str¶
Gets the name of a node from its collapsed index.
- Parameters
collapsed_index – Collapsed index of the node.
- Returns
Name of the node.
- conditional_bn(*args, **kwargs)¶
Overloaded function.
conditional_bn(self: pybnesian.models.BayesianNetworkBase) -> pybnesian.models.ConditionalBayesianNetworkBase
Returns the conditional Bayesian network version of this Bayesian network.
If
self
is not conditional, it returns a conditional version of the Bayesian network where the graph is transformed usingDag.conditional_graph
.If
self
is conditional, it returns a copy ofself
.
- Returns
The conditional graph transformation of
self
.
conditional_bn(self: pybnesian.models.BayesianNetworkBase, nodes: List[str], interface_nodes: List[str]) -> pybnesian.models.ConditionalBayesianNetworkBase
Returns the conditional Bayesian network version of this Bayesian network.
If
self
is not conditional, it returns a conditional version of the Bayesian network where the graph is transformed usingDag.conditional_graph
using the given set of nodes and interface nodes.If
self
is conditional, it returns a copy ofself
.
- Returns
The conditional graph transformation of
self
.
- contains_node(self: pybnesian.models.BayesianNetworkBase, node: str) → bool¶
Tests whether the node is in the Bayesian network or not.
- Parameters
node – Name of the node.
- Returns
True if the Bayesian network contains the node, False otherwise.
- cpd(self: pybnesian.models.BayesianNetworkBase, node: str) → pybnesian.factors.Factor¶
Returns the conditional probability distribution (CPD) associated to
node
. This is aFactor
type.- Parameters
node – A node name.
- Returns
The
Factor
associated tonode
- Raises
ValueError – If
node
do not have an associatedFactor
yet.
- fit(self: pybnesian.models.BayesianNetworkBase, df: DataFrame) → None¶
Fit all the unfitted
Factor
with the datadf
.- Parameters
df – DataFrame to fit the Bayesian network.
- fitted(self: pybnesian.models.BayesianNetworkBase) → bool¶
Checks whether the model is fitted.
- Returns
True if the model is fitted, False otherwise.
- flip_arc(self: pybnesian.models.BayesianNetworkBase, source: str, target: str) → None¶
Flips (reverses) an arc between the nodes
source
andtarget
. If the arc do not exist, the graph is left unaffected.- Parameters
source – A node name.
target – A node name.
- force_type_whitelist(self: pybnesian.models.BayesianNetworkBase, type_whitelist: List[Tuple[str, pybnesian.factors.FactorType]]) → None¶
Forces the Bayesian network to have the given whitelisted node types.
- Parameters
type_whitelist – List of node type tuples (
node
,FactorType
) that specifies the whitelisted type for each node.
- force_whitelist(self: pybnesian.models.BayesianNetworkBase, arc_whitelist: List[Tuple[str, str]]) → None¶
Include the given whitelisted arcs. It checks the validity of the graph after including the arc whitelist.
- Parameters
arc_whitelist – List of arcs tuples (
source
,target
) that must be added to the graph.
- has_arc(self: pybnesian.models.BayesianNetworkBase, source: str, target: str) → bool¶
Checks whether an arc between the nodes
source
andtarget
exists.- Parameters
source – A node name.
target – A node name.
- Returns
True if the arc exists, False otherwise.
- has_path(self: pybnesian.models.BayesianNetworkBase, n1: str, n2: str) → bool¶
Checks whether there is a directed path between nodes
n1
andn2
.- Parameters
n1 – A node name.
n2 – A node name.
- Returns
True if there is an directed path between
n1
andn2
, False otherwise.
- has_unknown_node_types(self: pybnesian.models.BayesianNetworkBase) → bool¶
Checks whether there are nodes with an unknown node type (i.e.
UnknownFactorType
).- Returns
True if there are nodes with an unkown node type, False otherwise.
- property include_cpd¶
This property indicates if the factors of the Bayesian network model should be saved when
__getstate__
is called.
- index(self: pybnesian.models.BayesianNetworkBase, node: str) → int¶
Gets the index of a node from its name.
- Parameters
node – Name of the node.
- Returns
Index of the node.
- index_from_collapsed(self: pybnesian.models.BayesianNetworkBase, collapsed_index: int) → int¶
Gets the index of a node from its collapsed index.
- Parameters
collapsed_index – Collapsed index of the node.
- Returns
Index of the node.
- indices(self: pybnesian.models.BayesianNetworkBase) → Dict[str, int]¶
Gets all the indices in the graph.
- Returns
A dictionary with the index of each node.
- is_valid(self: pybnesian.models.BayesianNetworkBase, node: str) → bool¶
Checks whether a node is valid (the node is not removed).
- Parameters
node – Node name.
- Returns
True if the node is valid, False otherwise.
- logl(self: pybnesian.models.BayesianNetworkBase, df: DataFrame) → numpy.ndarray[numpy.float64[m, 1]]¶
Returns the log-likelihood of each instance in the DataFrame
df
. This returns the sum of the log-likelihood for all the factors in the Bayesian network.- Parameters
df – DataFrame to compute the log-likelihood.
- Returns
A
numpy.ndarray
vector with dtypenumpy.float64
, where the i-th value is the log-likelihod of the i-th instance ofdf
.
- name(self: pybnesian.models.BayesianNetworkBase, index: int) → str¶
Gets the name of a node from its index.
- Parameters
index – Index of the node.
- Returns
Name of the node.
- node_type(self: pybnesian.models.BayesianNetworkBase, node: str) → pybnesian.factors.FactorType¶
Gets the corresponding
FactorType
fornode
.- Parameters
node – A node name.
- Returns
The
FactorType
ofnode
.
- node_types(self: pybnesian.models.BayesianNetworkBase) → Dict[str, pybnesian.factors.FactorType]¶
Gets the
FactorType
for all the nodes.- Returns
The corresponding
FactorType
for each node.
- nodes(self: pybnesian.models.BayesianNetworkBase) → List[str]¶
Gets the nodes of the Bayesian network.
- Returns
Nodes of the Bayesian network.
- num_arcs(self: pybnesian.models.BayesianNetworkBase) → int¶
Gets the number of arcs.
- Returns
Number of arcs.
- num_children(self: pybnesian.models.BayesianNetworkBase, node: str) → int¶
Gets the number of children nodes of a node.
- Parameters
node – A node name.
- Returns
Number of children nodes.
- num_nodes(self: pybnesian.models.BayesianNetworkBase) → int¶
Gets the number of nodes.
- Returns
Number of nodes.
- num_parents(self: pybnesian.models.BayesianNetworkBase, node: str) → int¶
Gets the number of parent nodes of a node.
- Parameters
node – A node name.
- Returns
Number of parent nodes.
- parents(self: pybnesian.models.BayesianNetworkBase, node: str) → List[str]¶
Gets the parent nodes of a node.
- Parameters
node – A node name.
- Returns
Parent node names.
- remove_arc(self: pybnesian.models.BayesianNetworkBase, source: str, target: str) → None¶
Removes an arc between the nodes
source
andtarget
. If the arc do not exist, the graph is left unaffected.- Parameters
source – A node name.
target – A node name.
- remove_node(self: pybnesian.models.BayesianNetworkBase, node: str) → None¶
Removes a node.
- Parameters
node – A node name.
- sample(self: pybnesian.models.BayesianNetworkBase, n: int, seed: Optional[int] = None, ordered: bool = False) → DataFrame¶
Samples
n
values from this BayesianNetwork. This method returns apyarrow.RecordBatch
withn
instances.If
ordered
is True, it orders the columns according to the listBayesianNetworkBase.nodes()
. Else, it orders the columns according to a topological sort.- Parameters
n – Number of instances to sample.
seed – A random seed number. If not specified or
None
, a random seed is generated.ordered – If True, order the columns according to
BayesianNetworkBase.nodes()
.
- Returns
A DataFrame with
n
instances that contains the sampled data.
- save(self: pybnesian.models.BayesianNetworkBase, filename: str, include_cpd: bool) → None¶
Saves the Bayesian network in a pickle file with the given name. If
include_cpd
is True, it also saves the conditional probability distributions (CPDs) in the Bayesian network.- Parameters
filename – File name of the saved Bayesian network.
include_cpd – Include the CPDs.
- set_node_type(self: pybnesian.models.BayesianNetworkBase, node: str, new_type: pybnesian.factors.FactorType) → None¶
Sets the
new_type
FactorType
fornode
.- Parameters
node – A node name.
new_type – The new
FactorType
fornode
.
- set_unknown_node_types(self: pybnesian.models.BayesianNetworkBase, df: DataFrame) → None¶
Changes the unknown node types (i.e. the nodes with
UnknownFactorType
) to the default node type specified by theBayesianNetworkType
.- Parameters
df – DataFrame to get the default node type for each unknown node type.
- slogl(self: pybnesian.models.BayesianNetworkBase, df: DataFrame) → float¶
Returns the sum of the log-likelihood of each instance in the DataFrame
df
. That is, the sum of the result ofBayesianNetworkBase.logl()
.- Parameters
df – DataFrame to compute the sum of the log-likelihood.
- Returns
The sum of log-likelihood for DataFrame
df
.
- type(self: pybnesian.models.BayesianNetworkBase) → pybnesian.models.BayesianNetworkType¶
Gets the underlying
BayesianNetworkType
.- Returns
The
BayesianNetworkType
ofself
.
- unconditional_bn(self: pybnesian.models.BayesianNetworkBase) → pybnesian.models.BayesianNetworkBase¶
Returns the unconditional Bayesian network version of this Bayesian network.
If
self
is not conditional, it returns a copy ofself
.If
self
is conditional, the interface nodes are included as nodes in the returned Bayesian network.
- Returns
The unconditional graph transformation of
self
.
- class pybnesian.models.ConditionalBayesianNetworkBase¶
Bases:
pybnesian.models.BayesianNetworkBase
This class defines an interface of base operations for the conditional Bayesian networks.
It includes some methods of the
ConditionalDag
to simplify the access to the graph.- add_interface_node(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → int¶
Adds an interface node to the Bayesian network and returns its index.
- Parameters
node – Name of the new interface node.
- Returns
Index of the new interface node.
- clone(self: pybnesian.models.ConditionalBayesianNetworkBase) → pybnesian.models.ConditionalBayesianNetworkBase¶
Clones (copies) this Bayesian network.
- Returns
A copy of
self
.
- contains_interface_node(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → bool¶
Tests whether the interface node is in the Bayesian network or not.
- Parameters
node – Name of the node.
- Returns
True if the Bayesian network contains the interface node, False otherwise.
- contains_joint_node(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → bool¶
Tests whether the node is in the joint set of nodes or not.
- Parameters
node – Name of the node.
- Returns
True if the node is in the joint set of nodes, False otherwise.
- index_from_interface_collapsed(self: pybnesian.models.ConditionalBayesianNetworkBase, collapsed_index: int) → int¶
Gets the index of a node from the interface collapsed index.
- Parameters
collapsed_index – Interface collapsed index of the node.
- Returns
Index of the node.
- index_from_joint_collapsed(self: pybnesian.models.ConditionalBayesianNetworkBase, collapsed_index: int) → int¶
Gets the index of a node from the joint collapsed index.
- Parameters
collapsed_index – Joint collapsed index of the node.
- Returns
Index of the node.
- interface_collapsed_from_index(self: pybnesian.models.ConditionalBayesianNetworkBase, index: int) → int¶
Gets the interface collapsed index of a node from its index.
- Parameters
index – Index of the node.
- Returns
Interface collapsed index of the node.
- interface_collapsed_index(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → int¶
Gets the interface collapsed index of an interface node from its name.
- Parameters
node – Name of the interface node.
- Returns
Interface collapsed index of the interface node.
- interface_collapsed_indices(self: pybnesian.models.ConditionalBayesianNetworkBase) → Dict[str, int]¶
Gets all the interface collapsed indices for the interface nodes in the graph.
- Returns
A dictionary with the interface collapsed index of each interface node.
- interface_collapsed_name(self: pybnesian.models.ConditionalBayesianNetworkBase, collapsed_index: int) → str¶
Gets the name of an interface node from its collapsed index.
- Parameters
collapsed_index – Collapsed index of the interface node.
- Returns
Name of the interface node.
- interface_nodes(self: pybnesian.models.ConditionalBayesianNetworkBase) → List[str]¶
Gets the interface nodes of the Bayesian network.
- Returns
Interface nodes of the Bayesian network.
- is_interface(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → bool¶
Checks whether the
node
is an interface node.- Parameters
node – A node name.
- Returns
True if
node
is interface node, False, otherwise.
- joint_collapsed_from_index(self: pybnesian.models.ConditionalBayesianNetworkBase, index: int) → int¶
Gets the joint collapsed index of a node from its index.
- Parameters
index – Index of the node.
- Returns
Joint collapsed index of the node.
- joint_collapsed_index(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → int¶
Gets the joint collapsed index of a node from its name.
- Parameters
node – Name of the node.
- Returns
Joint collapsed index of the node.
- joint_collapsed_indices(self: pybnesian.models.ConditionalBayesianNetworkBase) → Dict[str, int]¶
Gets all the joint collapsed indices for the joint set of nodes in the graph.
- Returns
A dictionary with the joint collapsed index of each joint node.
- joint_collapsed_name(self: pybnesian.models.ConditionalBayesianNetworkBase, collapsed_index: int) → str¶
Gets the name of a node from its joint collapsed index.
- Parameters
collapsed_index – Joint collapsed index of the node.
- Returns
Name of the node.
- joint_nodes(self: pybnesian.models.ConditionalBayesianNetworkBase) → List[str]¶
Gets the joint set of nodes of the Bayesian network.
- Returns
Joint set of nodes of the Bayesian network.
- num_interface_nodes(self: pybnesian.models.ConditionalBayesianNetworkBase) → int¶
Gets the number of interface nodes.
- Returns
Number of interface nodes.
- num_joint_nodes(self: pybnesian.models.ConditionalBayesianNetworkBase) → int¶
Gets the number of joint nodes. That is,
num_nodes() + num_interface_nodes()
- Returns
Number of joint nodes.
- remove_interface_node(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → None¶
Removes an interface node.
- Parameters
node – A node name.
- sample(self: pybnesian.models.ConditionalBayesianNetworkBase, evidence: DataFrame, seed: Optional[int] = None, concat_evidence: bool = False, ordered: bool = False) → DataFrame¶
Samples
n
values from this conditional BayesianNetwork conditioned onevidence
.evidence
must contain a column for each interface node. This method returns apyarrow.RecordBatch
withn
instances.If
concat
is True, it concatenatesevidence
in the result.If
ordered
is True, it orders the columns according to the listBayesianNetworkBase.nodes()
. Else, it orders the columns according to a topological sort.- Parameters
n – Number of instances to sample.
evidence – A DataFrame of
n
instances to condition the sampling.seed – A random seed number. If not specified or
None
, a random seed is generated.ordered – If True, order the columns according to
BayesianNetworkBase.nodes()
.
- Returns
A DataFrame with
n
instances that contains the sampled data.
- set_interface(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → None¶
Converts a normal node into an interface node.
- Parameters
node – A node name.
- set_node(self: pybnesian.models.ConditionalBayesianNetworkBase, node: str) → None¶
Converts an interface node into a normal node.
- Parameters
node – A node name.
- class pybnesian.models.DynamicBayesianNetworkBase¶
This class defines an interface of a dynamic Bayesian network.
A dynamic Bayesian network is defined over a set of variables. Each variable is replicated in different nodes (one for each temporal slice). Thus, we differentiate in this documentation between the terms “variable” and “node”. To create the nodes, we suffix the variable names using the structure
[variable_name]_t_[temporal_index]
. Thevariable_name
is the name of each variable, andtemporal_index
is an index with a range [0-markovian_order
]. The index “0” is considered the “present”, the index “1” delays the temporal one step into the “past”, and so on… This is related with the wayDynamicDataFrame
generates the columns.The dynamic Bayesian is composed of two Bayesian networks:
a static Bayesian network that defines the probability distribution of the first
markovian_order
instances. It estimates the probability f(t_1
,…,t_[markovian_order]
). This Bayesian network is represented with a normal Bayesian network.a transition Bayesian network that defines the probability distribution of the i-th instance given the previous
markovian_order
instances. It estimates the probability f(t_0
|t_1
, …,t_[markovian_order]
), wheret_0
(the present) is the i-th instance. Once the probability of the i-th instance is estimated, the transition network moves a step forward, to estimate the (i+1)-th instance, and so on. This transition Bayesian network is represented with a conditional Bayesian network.
Both Bayesian networks must be of the same
BayesianNetworkType
.- __str__(self: pybnesian.models.DynamicBayesianNetworkBase) → str¶
- add_variable(self: pybnesian.models.DynamicBayesianNetworkBase, variable: str) → None¶
Adds a variable to the dynamic Bayesian network. It adds a node for each temporal slice in the static and transition Bayesian networks.
- Parameters
variable – Name of the new variable.
- contains_variable(self: pybnesian.models.DynamicBayesianNetworkBase, variable: str) → bool¶
Tests whether the variable is in the dynamic Bayesian network or not.
- Parameters
variable – Name of the variable.
- Returns
True if the dynamic Bayesian network contains the variable, False otherwise.
- fit(self: pybnesian.models.DynamicBayesianNetworkBase, df: DataFrame) → None¶
Fit all the unfitted
Factor
with the datadf
in both the static and transition Bayesian networks.- Parameters
df – DataFrame to fit the dynamic Bayesian network.
- fitted(self: pybnesian.models.DynamicBayesianNetworkBase) → bool¶
Checks whether the model is fitted.
- Returns
True if the model is fitted, False otherwise.
- logl(self: pybnesian.models.DynamicBayesianNetworkBase, df: DataFrame) → numpy.ndarray[numpy.float64[m, 1]]¶
Returns the log-likelihood of each instance in the DataFrame
df
.- Parameters
df – DataFrame to compute the log-likelihood.
- Returns
A
numpy.ndarray
vector with dtypenumpy.float64
, where the i-th value is the log-likelihood of the i-th instance ofdf
.
- markovian_order(self: pybnesian.models.DynamicBayesianNetworkBase) → int¶
Gets the markovian order of the dynamic Bayesian network.
- Returns
markovian order of this dynamic Bayesian network.
- num_variables(self: pybnesian.models.DynamicBayesianNetworkBase) → int¶
Gets the number of variables.
- Returns
Number of variables.
- remove_variable(self: pybnesian.models.DynamicBayesianNetworkBase, variable: str) → None¶
Removes a variable. It removes all the corresponding nodes in the static and transition Bayesian networks.
- Parameters
variable – A variable name.
- sample(self: pybnesian.models.DynamicBayesianNetworkBase, n: int, seed: Optional[int] = None) → DataFrame¶
Samples
n
values from this dynamic Bayesian network. This method returns apyarrow.RecordBatch
withn
instances.- Parameters
n – Number of instances to sample.
seed – A random seed number. If not specified or
None
, a random seed is generated.
- save(self: pybnesian.models.DynamicBayesianNetworkBase, filename: str, include_cpd: bool) → None¶
Saves the dynamic Bayesian network in a pickle file with the given name. If
include_cpd
is True, it also saves the conditional probability distributions (CPDs) in the dynamic Bayesian network.- Parameters
filename – File name of the saved dynamic Bayesian network.
include_cpd – Include the CPDs.
- slogl(self: pybnesian.models.DynamicBayesianNetworkBase, df: DataFrame) → float¶
Returns the sum of the log-likelihood of each instance in the DataFrame
df
. That is, the sum of the result ofDynamicBayesianNetworkBase.logl()
.- Parameters
df – DataFrame to compute the sum of the log-likelihood.
- Returns
The sum of log-likelihood for DataFrame
df
.
- static_bn(self: pybnesian.models.DynamicBayesianNetworkBase) → pybnesian.models.BayesianNetworkBase¶
Returns the static Bayesian network.
- Returns
Static Bayesian network.
- transition_bn(self: pybnesian.models.DynamicBayesianNetworkBase) → pybnesian.models.ConditionalBayesianNetworkBase¶
Returns the transition Bayesian network.
- Returns
Transition Bayesian network.
- type(self: pybnesian.models.DynamicBayesianNetworkBase) → pybnesian.models.BayesianNetworkType¶
Gets the underlying
BayesianNetworkType
.- Returns
The
BayesianNetworkType
ofself
.
- variables(self: pybnesian.models.DynamicBayesianNetworkBase) → List[str]¶
Gets the variables of the dynamic Bayesian network.
- Returns
Variables of the dynamic Bayesian network.
Bayesian Network Types¶
- class pybnesian.models.GaussianNetworkType¶
Bases:
pybnesian.models.BayesianNetworkType
This
BayesianNetworkType
represents a Gaussian network: homogeneous withLinearGaussianCPD
factors.- __init__(self: pybnesian.models.GaussianNetworkType) → None¶
- class pybnesian.models.SemiparametricBNType¶
Bases:
pybnesian.models.BayesianNetworkType
This
BayesianNetworkType
represents a semiparametric Bayesian network: non-homogeneous withLinearGaussianCPD
andCKDE
factors for continuous data. The default isLinearGaussianCPD
. It also supports discrete data usingDiscreteFactor
.In a SemiparametricBN network, the discrete nodes can only have discrete parents.
- __init__(self: pybnesian.models.SemiparametricBNType) → None¶
- class pybnesian.models.KDENetworkType¶
Bases:
pybnesian.models.BayesianNetworkType
This
BayesianNetworkType
represents a KDE Bayesian network: homogeneous withCKDE
factors.- __init__(self: pybnesian.models.KDENetworkType) → None¶
- class pybnesian.models.DiscreteBNType¶
Bases:
pybnesian.models.BayesianNetworkType
This
BayesianNetworkType
represents a discrete Bayesian network: homogeneous withDiscreteFactor
factors.- __init__(self: pybnesian.models.DiscreteBNType) → None¶
- class pybnesian.models.HomogeneousBNType¶
Bases:
pybnesian.models.BayesianNetworkType
- __init__(self: pybnesian.models.HomogeneousBNType, default_factor_type: pybnesian.factors.FactorType) → None¶
Initializes an
HomogeneousBNType
with a default node type.- Parameters
default_factor_type – Default factor type for all the nodes in the Bayesian network.
- class pybnesian.models.HeterogeneousBNType¶
Bases:
pybnesian.models.BayesianNetworkType
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.HeterogeneousBNType, default_factor_type: pybnesian.factors.FactorType) -> None
Initializes an
HeterogeneousBNType
with a default node type for all the data types.- Parameters
default_factor_type – Default factor type for all the nodes in the Bayesian network.
__init__(self: pybnesian.models.HeterogeneousBNType, default_factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType]) -> None
Initializes an
HeterogeneousBNType
with a default node type for a set of data types.- Parameters
default_factor_type – Default factor type depending on the factor type.
- default_node_types(self: pybnesian.models.HeterogeneousBNType) → Dict[pyarrow.DataType, pybnesian.factors.FactorType]¶
Returns the dict of default
FactorType
for each data type.- Returns
dict of default
FactorType
for each data type.
- single_default(self: pybnesian.models.HeterogeneousBNType) → bool¶
Checks whether the
HeterogeneousBNType
defines only a defaultFactorType
for all the data types.- Returns
True if it defines a single
FactorType
for all the data types. False if different defaultFactorType
is defined for different data types.
Bayesian Networks¶
- class pybnesian.models.BayesianNetwork¶
Bases:
pybnesian.models.BayesianNetworkBase
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str]) -> None
Initializes the
BayesianNetwork
with a giventype
andnodes
.- Parameters
type –
BayesianNetworkType
of this Bayesian network.nodes – List of node names.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
BayesianNetwork
with a giventype
andnodes
. It specifies thenode_types
for the nodes.- Parameters
type –
BayesianNetworkType
of this Bayesian network.nodes – List of node names.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, arcs: List[Tuple[str, str]]) -> None
Initializes the
BayesianNetwork
with a giventype
andarcs
(the nodes are extracted from the arcs).- Parameters
type –
BayesianNetworkType
of this Bayesian network.arcs – Arcs of the Bayesian network.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, arcs: List[Tuple[str, str]], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
BayesianNetwork
with a giventype
andarcs
(the nodes are extracted from the arcs). It specifies thenode_types
for the nodes.- Parameters
type –
BayesianNetworkType
of this Bayesian network.arcs – Arcs of the Bayesian network.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
BayesianNetwork
with a giventype
,nodes
andarcs
.- Parameters
type –
BayesianNetworkType
of this Bayesian network.nodes – List of node names.
arcs – Arcs of the Bayesian network.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str], arcs: List[Tuple[str, str]], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
BayesianNetwork
with a giventype
,nodes
andarcs
. It specifies thenode_types
for the nodes.- Parameters
type –
BayesianNetworkType
of this Bayesian network.nodes – List of node names.
arcs – Arcs of the Bayesian network.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, graph: pybnesian.graph.Dag) -> None
Initializes the
BayesianNetwork
with a giventype
, andgraph
- Parameters
type –
BayesianNetworkType
of this Bayesian network.graph –
Dag
of the Bayesian network.
__init__(self: pybnesian.models.BayesianNetwork, type: pybnesian.models.BayesianNetworkType, graph: pybnesian.graph.Dag, node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
BayesianNetwork
with a giventype
, andgraph
. It specifies thenode_types
for the nodes.- Parameters
type –
BayesianNetworkType
of this Bayesian network.graph –
Dag
of the Bayesian network.node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
- can_have_cpd(self: pybnesian.models.BayesianNetwork, node: str) → bool¶
Checks whether a given node name can have an associated CPD. For
- Parameters
node – A node name.
- Returns
True if the given node can have a CPD, False otherwise.
- check_compatible_cpd(self: pybnesian.models.BayesianNetwork, cpd: pybnesian.factors.Factor) → None¶
Checks whether the given CPD is compatible with this Bayesian network.
- Parameters
cpd – A
Factor
.- Returns
True if
cpd
is compatible with this Bayesian network, False otherwise.
- graph(self: pybnesian.models.BayesianNetwork) → pybnesian.graph.Dag¶
Gets the underlying graph of the Bayesian network.
- Returns
Graph of the Bayesian network.
Concrete Bayesian Networks¶
These classes implements BayesianNetwork
with an specific BayesianNetworkType
. Thus, the constructors
do not have the type
parameter.
- class pybnesian.models.GaussianNetwork¶
Bases:
pybnesian.models.BayesianNetwork
This class implements a
BayesianNetwork
with the typeGaussianNetworkType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.GaussianNetwork, nodes: List[str]) -> None
Initializes the
GaussianNetwork
with the givennodes
.- Parameters
nodes – List of node names.
__init__(self: pybnesian.models.GaussianNetwork, arcs: List[Tuple[str, str]]) -> None
Initializes the
GaussianNetwork
with the givenarcs
(the nodes are extracted from the arcs).- Parameters
arcs – Arcs of the
GaussianNetwork
.
__init__(self: pybnesian.models.GaussianNetwork, nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
GaussianNetwork
with the givennodes
andarcs
.- Parameters
nodes – List of node names.
arcs – Arcs of the
GaussianNetwork
.
__init__(self: pybnesian.models.GaussianNetwork, graph: pybnesian.graph.Dag) -> None
Initializes the
GaussianNetwork
with the givengraph
.- Parameters
graph –
Dag
of the Bayesian network.
- class pybnesian.models.SemiparametricBN¶
Bases:
pybnesian.models.BayesianNetwork
This class implements a
BayesianNetwork
with the typeSemiparametricBNType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.SemiparametricBN, nodes: List[str]) -> None
Initializes the
SemiparametricBN
with the givennodes
.- Parameters
nodes – List of node names.
__init__(self: pybnesian.models.SemiparametricBN, arcs: List[Tuple[str, str]]) -> None
Initializes the
SemiparametricBN
with the givenarcs
(the nodes are extracted from the arcs).- Parameters
arcs – Arcs of the
SemiparametricBN
.
__init__(self: pybnesian.models.SemiparametricBN, nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
SemiparametricBN
with the givennodes
andarcs
.- Parameters
nodes – List of node names.
arcs – Arcs of the
SemiparametricBN
.
__init__(self: pybnesian.models.SemiparametricBN, graph: pybnesian.graph.Dag) -> None
Initializes the
SemiparametricBN
with the givengraph
.- Parameters
graph –
Dag
of the Bayesian network.
__init__(self: pybnesian.models.SemiparametricBN, nodes: List[str], node_Types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
SemiparametricBN
with the givennodes
. It specifies thenode_types
for the nodes.- Parameters
nodes – List of node names.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.SemiparametricBN, arcs: List[Tuple[str, str]], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
SemiparametricBN
with the givenarcs
(the nodes are extracted from the arcs). It specifies thenode_types
for the nodes.- Parameters
arcs – Arcs of the SemiparametricBN.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.SemiparametricBN, nodes: List[str], arcs: List[Tuple[str, str]], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
SemiparametricBN
with the givennodes
andarcs
. It specifies thenode_types
for the nodes.- Parameters
nodes – List of node names.
arcs – Arcs of the
SemiparametricBN
.node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.SemiparametricBN, graph: pybnesian.graph.Dag, node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
SemiparametricBN
with the givengraph
. It specifies thenode_types
for the nodes.- Parameters
graph –
Dag
of the Bayesian network.node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
- class pybnesian.models.KDENetwork¶
Bases:
pybnesian.models.BayesianNetwork
This class implements a
BayesianNetwork
with the typeKDENetworkType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.KDENetwork, nodes: List[str]) -> None
Initializes the
KDENetwork
with the givennodes
.- Parameters
nodes – List of node names.
__init__(self: pybnesian.models.KDENetwork, arcs: List[Tuple[str, str]]) -> None
Initializes the
KDENetwork
with the givenarcs
(the nodes are extracted from the arcs).- Parameters
arcs – Arcs of the
KDENetwork
.
__init__(self: pybnesian.models.KDENetwork, nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
KDENetwork
with the givennodes
andarcs
.- Parameters
nodes – List of node names.
arcs – Arcs of the
KDENetwork
.
__init__(self: pybnesian.models.KDENetwork, graph: pybnesian.graph.Dag) -> None
Initializes the
KDENetwork
with the givengraph
.- Parameters
graph –
Dag
of the Bayesian network.
- class pybnesian.models.DiscreteBN¶
Bases:
pybnesian.models.BayesianNetwork
This class implements a
BayesianNetwork
with the typeDiscreteBNType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DiscreteBN, nodes: List[str]) -> None
Initializes the
DiscreteBN
with the givennodes
.- Parameters
nodes – List of node names.
__init__(self: pybnesian.models.DiscreteBN, arcs: List[Tuple[str, str]]) -> None
Initializes the
DiscreteBN
with the givenarcs
(the nodes are extracted from the arcs).- Parameters
arcs – Arcs of the
DiscreteBN
.
__init__(self: pybnesian.models.DiscreteBN, nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
DiscreteBN
with the givennodes
andarcs
.- Parameters
nodes – List of node names.
arcs – Arcs of the
DiscreteBN
.
__init__(self: pybnesian.models.DiscreteBN, graph: pybnesian.graph.Dag) -> None
Initializes the
DiscreteBN
with the givengraph
.- Parameters
graph –
Dag
of the Bayesian network.
- class pybnesian.models.HomogeneousBN¶
Bases:
pybnesian.models.BayesianNetwork
This class implements an homogeneous Bayesian network. This Bayesian network can be used with any
FactorType
. You can set theFactorType
in the constructor.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.HomogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str]) -> None
Initializes the
HomogeneousBN
offactor_type
with the givennodes
.- Parameters
factor_type –
FactorType
for all the nodes.nodes – List of node names.
__init__(self: pybnesian.models.HomogeneousBN, factor_type: pybnesian.factors.FactorType, arcs: List[Tuple[str, str]]) -> None
Initializes the
HomogeneousBN
offactor_type
with the givenarcs
(the nodes are extracted from the arcs).- Parameters
factor_type –
FactorType
for all the nodes.arcs – Arcs of the
HomogeneousBN
.
__init__(self: pybnesian.models.HomogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
HomogeneousBN
offactor_type
with the givennodes
andarcs
.- Parameters
factor_type –
FactorType
for all the nodes.nodes – List of node names.
arcs – Arcs of the
HomogeneousBN
.
__init__(self: pybnesian.models.HomogeneousBN, factor_type: pybnesian.factors.FactorType, graph: pybnesian.graph.Dag) -> None
Initializes the
HomogeneousBN
offactor_type
with the givengraph
.- Parameters
factor_type –
FactorType
for all the nodes.graph –
Dag
of the Bayesian network.
- class pybnesian.models.HeterogeneousBN¶
Bases:
pybnesian.models.BayesianNetwork
This class implements an heterogeneous Bayesian network. This Bayesian network accepts a different
FactorType
for each node. You can set the defaultFactorType
in the constructor.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.HeterogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str]) -> None
Initializes the
HeterogeneousBN
of defaultfactor_type
with the givennodes
.- Parameters
factor_type – Default
FactorType
for the Bayesian network.nodes – List of node names.
__init__(self: pybnesian.models.HeterogeneousBN, factor_type: pybnesian.factors.FactorType, arcs: List[Tuple[str, str]]) -> None
Initializes the
HeterogeneousBN
of defaultfactor_type
with the givenarcs
(the nodes are extracted from the arcs).- Parameters
factor_type – Default
FactorType
for the Bayesian network.arcs – Arcs of the
HeterogeneousBN
.
__init__(self: pybnesian.models.HeterogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
HeterogeneousBN
of defaultfactor_type
with the givennodes
andarcs
.- Parameters
factor_type – Default
FactorType
for the Bayesian network.nodes – List of node names.
arcs – Arcs of the
HeterogeneousBN
.
__init__(self: pybnesian.models.HeterogeneousBN, factor_type: pybnesian.factors.FactorType, graph: pybnesian.graph.Dag) -> None
Initializes the
HeterogeneousBN
of defaultfactor_type
with the givengraph
.- Parameters
factor_type – Default
FactorType
for the Bayesian network.graph –
Dag
of the Bayesian network.
__init__(self: pybnesian.models.HeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], nodes: List[str]) -> None
Initializes the
HeterogeneousBN
of different defaultfactor_types
, with the givennodes
.- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.nodes – List of node names.
__init__(self: pybnesian.models.HeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], arcs: List[Tuple[str, str]]) -> None
Initializes the
HeterogeneousBN
of different defaultfactor_types
with the givenarcs
(the nodes are extracted from the arcs).- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.arcs – Arcs of the
HeterogeneousBN
.
__init__(self: pybnesian.models.HeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
HeterogeneousBN
of different defaultfactor_types
with the givennodes
andarcs
.- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.nodes – List of node names.
arcs – Arcs of the
HeterogeneousBN
.
__init__(self: pybnesian.models.HeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], graph: pybnesian.graph.Dag) -> None
Initializes the
HeterogeneousBN
of different defaultfactor_types
with the givengraph
.- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.graph –
Dag
of the Bayesian network.
Conditional Bayesian Networks¶
- class pybnesian.models.ConditionalBayesianNetwork¶
Bases:
pybnesian.models.ConditionalBayesianNetworkBase
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.ConditionalBayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalBayesianNetwork
with a giventype
,nodes
andinterface_nodes
.- Parameters
type –
BayesianNetworkType
of this conditional Bayesian network.nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalBayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str], interface_nodes: List[str], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
ConditionalBayesianNetwork
with a giventype
,nodes
andinterface_nodes
. It specifies thenode_types
for the nodes.- Parameters
type –
BayesianNetworkType
of this conditional Bayesian network.nodes – List of node names.
interface_nodes – List of interface node names.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.ConditionalBayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalBayesianNetwork
with a giventype
,nodes
,interface_nodes
andarcs
.- Parameters
type –
BayesianNetworkType
of this conditional Bayesian network.nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the conditional Bayesian network.
__init__(self: pybnesian.models.ConditionalBayesianNetwork, type: pybnesian.models.BayesianNetworkType, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
ConditionalBayesianNetwork
with a giventype
,nodes
,interface_nodes
andarcs
. It specifies thenode_types
for the nodes.- Parameters
type –
BayesianNetworkType
of this conditional Bayesian network.nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the conditional Bayesian network.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.ConditionalBayesianNetwork, type: pybnesian.models.BayesianNetworkType, graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalBayesianNetwork
with a giventype
, andgraph
- Parameters
type –
BayesianNetworkType
of this conditional Bayesian network.graph –
ConditionalDag
of the conditional Bayesian network.
__init__(self: pybnesian.models.ConditionalBayesianNetwork, type: pybnesian.models.BayesianNetworkType, graph: pybnesian.graph.ConditionalDag, node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
ConditionalBayesianNetwork
with a giventype
, andgraph
. It specifies thenode_types
for the nodes.- Parameters
type –
BayesianNetworkType
of this conditional Bayesian network.graph –
ConditionalDag
of the conditional Bayesian network.node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
- can_have_cpd(self: pybnesian.models.ConditionalBayesianNetwork, node: str) → bool¶
Checks whether a given node name can have an associated CPD. For
- Parameters
node – A node name.
- Returns
True if the given node can have a CPD, False otherwise.
- check_compatible_cpd(self: pybnesian.models.ConditionalBayesianNetwork, cpd: pybnesian.factors.Factor) → None¶
Checks whether the given CPD is compatible with this Bayesian network.
- Parameters
cpd – A
Factor
.- Returns
True if
cpd
is compatible with this Bayesian network, False otherwise.
- graph(self: pybnesian.models.ConditionalBayesianNetwork) → pybnesian.graph.ConditionalDag¶
Gets the underlying graph of the Bayesian network.
- Returns
Graph of the Bayesian network.
Concrete Conditional Bayesian Networks¶
These classes implements ConditionalBayesianNetwork
with an specific BayesianNetworkType
.
Thus, the constructors do not have the type
parameter.
- class pybnesian.models.ConditionalGaussianNetwork¶
Bases:
pybnesian.models.ConditionalBayesianNetwork
This class implements a
ConditionalBayesianNetwork
with the typeGaussianNetworkType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.ConditionalGaussianNetwork, nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalGaussianNetwork
with the givennodes
andinterface_nodes
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalGaussianNetwork, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalGaussianNetwork
with the givennodes
,interface_nodes
andarcs
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalGaussianNetwork
.
__init__(self: pybnesian.models.ConditionalGaussianNetwork, graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalGaussianNetwork
with the givengraph
.- Parameters
graph –
ConditionalDag
of the conditional Bayesian network.
- class pybnesian.models.ConditionalSemiparametricBN¶
Bases:
pybnesian.models.ConditionalBayesianNetwork
This class implements a
ConditionalBayesianNetwork
with the typeSemiparametricBNType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.ConditionalSemiparametricBN, nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalSemiparametricBN
with the givennodes
andinterface_nodes
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalSemiparametricBN, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalSemiparametricBN
with the givennodes
,interface_nodes
andarcs
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalSemiparametricBN
.
__init__(self: pybnesian.models.ConditionalSemiparametricBN, graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalSemiparametricBN
with the givengraph
.- Parameters
graph –
ConditionalDag
of the conditional Bayesian network.
__init__(self: pybnesian.models.ConditionalSemiparametricBN, nodes: List[str], interface_nodes: List[str], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
ConditionalSemiparametricBN
with the givennodes
andinterface_nodes
. It specifies thenode_types
for the nodes.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.ConditionalSemiparametricBN, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]], node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
ConditionalSemiparametricBN
with the givennodes
,interface_nodes
andarcs
. It specifies thenode_types
for the nodes.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalSemiparametricBN
.node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
__init__(self: pybnesian.models.ConditionalSemiparametricBN, graph: pybnesian.graph.ConditionalDag, node_types: List[Tuple[str, pybnesian.factors.FactorType]]) -> None
Initializes the
ConditionalSemiparametricBN
with the givengraph
. It specifies thenode_types
for the nodes.- Parameters
graph –
ConditionalDag
of the conditional Bayesian network.node_types – List of node type tuples (
node
,FactorType
) that specifies the type for each node.
- class pybnesian.models.ConditionalKDENetwork¶
Bases:
pybnesian.models.ConditionalBayesianNetwork
This class implements a
ConditionalBayesianNetwork
with the typeKDENetworkType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.ConditionalKDENetwork, nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalKDENetwork
with the givennodes
andinterface_nodes
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalKDENetwork, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalKDENetwork
with the givennodes
,interface_nodes
andarcs
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalKDENetwork
.
__init__(self: pybnesian.models.ConditionalKDENetwork, graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalKDENetwork
with the givengraph
.- Parameters
graph –
ConditionalDag
of the conditional Bayesian network.
- class pybnesian.models.ConditionalDiscreteBN¶
Bases:
pybnesian.models.ConditionalBayesianNetwork
This class implements a
ConditionalBayesianNetwork
with the typeDiscreteBNType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.ConditionalDiscreteBN, nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalDiscreteBN
with the givennodes
andinterface_nodes
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalDiscreteBN, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalDiscreteBN
with the givennodes
,interface_nodes
andarcs
.- Parameters
nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalDiscreteBN
.
__init__(self: pybnesian.models.ConditionalDiscreteBN, graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalDiscreteBN
with the givengraph
.- Parameters
graph –
ConditionalDag
of the conditional Bayesian network.
- class pybnesian.models.ConditionalHomogeneousBN¶
Bases:
pybnesian.models.ConditionalBayesianNetwork
This class implements an homogeneous conditional Bayesian network. This conditional Bayesian network can be used with any
FactorType
. You can set theFactorType
in the constructor.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.ConditionalHomogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalHomogeneousBN
offactor_type
with the givennodes
andinterface_nodes
.- Parameters
factor_type –
FactorType
for all the nodes.nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalHomogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalHomogeneousBN
offactor_type
with the givennodes
,interface_nodes
andarcs
.- Parameters
factor_type –
FactorType
for all the nodes.nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalHomogeneousBN
.
__init__(self: pybnesian.models.ConditionalHomogeneousBN, factor_type: pybnesian.factors.FactorType, graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalHomogeneousBN
offactor_type
with the givengraph
.- Parameters
factor_type –
FactorType
for all the nodes.graph –
ConditionalDag
of the conditional Bayesian network.
- class pybnesian.models.ConditionalHeterogeneousBN¶
Bases:
pybnesian.models.ConditionalBayesianNetwork
This class implements an heterogeneous conditional Bayesian network. This conditional Bayesian network accepts a different
FactorType
for each node. You can set the defaultFactorType
in the constructor.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.ConditionalHeterogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalHeterogeneousBN
of defaultfactor_type
with the givennodes
andinterface_nodes
.- Parameters
factor_type – Default
FactorType
for the conditional Bayesian network.nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalHeterogeneousBN, factor_type: pybnesian.factors.FactorType, nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalHeterogeneousBN
of defaultfactor_type
with the givennodes
,interface_nodes
andarcs
.- Parameters
factor_type – Default
FactorType
for the conditional Bayesian network.nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalHeterogeneousBN
.
__init__(self: pybnesian.models.ConditionalHeterogeneousBN, factor_type: pybnesian.factors.FactorType, graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalHeterogeneousBN
of defaultfactor_type
with the givengraph
.- Parameters
factor_type – Default
FactorType
for the conditional Bayesian network.graph –
ConditionalDag
of the conditional Bayesian network.
__init__(self: pybnesian.models.ConditionalHeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], nodes: List[str], interface_nodes: List[str]) -> None
Initializes the
ConditionalHeterogeneousBN
of different defaultfactor_types
with the givennodes
andinterface_nodes
.- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.nodes – List of node names.
interface_nodes – List of interface node names.
__init__(self: pybnesian.models.ConditionalHeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], nodes: List[str], interface_nodes: List[str], arcs: List[Tuple[str, str]]) -> None
Initializes the
ConditionalHeterogeneousBN
of different defaultfactor_types
with the givennodes
,interface_nodes
andarcs
.- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.nodes – List of node names.
interface_nodes – List of interface node names.
arcs – Arcs of the
ConditionalHeterogeneousBN
.
__init__(self: pybnesian.models.ConditionalHeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], graph: pybnesian.graph.ConditionalDag) -> None
Initializes the
ConditionalHeterogeneousBN
of different defaultfactor_types
with the givengraph
.- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.graph –
ConditionalDag
of the conditional Bayesian network.
Dynamic Bayesian Networks¶
- class pybnesian.models.DynamicBayesianNetwork¶
Bases:
pybnesian.models.DynamicBayesianNetworkBase
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DynamicBayesianNetwork, type: pybnesian.models.BayesianNetworkType, variables: List[str], markovian_order: int) -> None
Initializes the
DynamicBayesianNetwork
with the givenvariables
andmarkovian_order
. It creates empty the static and transition Bayesian networks with the giventype
.- Parameters
type –
BayesianNetworkType
of the static and transition Bayesian networks.variables – List of node names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicBayesianNetwork, variables: List[str], markovian_order: int, static_bn: pybnesian.models.BayesianNetworkBase, transition_bn: pybnesian.models.ConditionalBayesianNetworkBase) -> None
Initializes the
DynamicBayesianNetwork
with the givenvariables
andmarkovian_order
. The static and transition Bayesian networks are initialized withstatic_bn
andtransition_bn
respectively.Both
static_bn
andtransition
must contain the expected nodes:For the static network, it must contain the nodes from
[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.For the transition network, it must contain the nodes
[variable_name]_t_0
, and the interface nodes from[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.
The static and transition networks must have the same
BayesianNetworkType
.- Parameters
variables – List of node names.
markovian_order – Markovian order of the dynamic Bayesian network.
static_bn – Static Bayesian network.
transition_bn – Transition Bayesian network.
Concrete Dynamic Bayesian Networks¶
These classes implements DynamicBayesianNetwork
with an specific BayesianNetworkType
. Thus, the
constructors do not have the type
parameter.
- class pybnesian.models.DynamicGaussianNetwork¶
Bases:
pybnesian.models.DynamicBayesianNetwork
This class implements a
DynamicBayesianNetwork
with the typeGaussianNetworkType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DynamicGaussianNetwork, variables: List[str], markovian_order: int) -> None
Initializes the
DynamicGaussianNetwork
with the givenvariables
andmarkovian_order
. It creates empty static and transition Bayesian networks.- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicGaussianNetwork, variables: List[str], markovian_order: int, static_bn: pybnesian.models.BayesianNetworkBase, transition_bn: pybnesian.models.ConditionalBayesianNetworkBase) -> None
Initializes the
DynamicGaussianNetwork
with the givenvariables
andmarkovian_order
. The static and transition Bayesian networks are initialized withstatic_bn
andtransition_bn
respectively.Both
static_bn
andtransition_bn
must contain the expected nodes:For the static network, it must contain the nodes from
[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.For the transition network, it must contain the nodes
[variable_name]_t_0
, and the interface nodes from[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.
- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
static_bn – Static Bayesian network.
transition_bn – Transition Bayesian network.
- class pybnesian.models.DynamicSemiparametricBN¶
Bases:
pybnesian.models.DynamicBayesianNetwork
This class implements a
DynamicBayesianNetwork
with the typeSemiparametricBNType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DynamicSemiparametricBN, variables: List[str], markovian_order: int) -> None
Initializes the
DynamicSemiparametricBN
with the givenvariables
andmarkovian_order
. It creates empty static and transition Bayesian networks.- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicSemiparametricBN, variables: List[str], markovian_order: int, static_bn: pybnesian.models.BayesianNetworkBase, transition_bn: pybnesian.models.ConditionalBayesianNetworkBase) -> None
Initializes the
DynamicSemiparametricBN
with the givenvariables
andmarkovian_order
. The static and transition Bayesian networks are initialized withstatic_bn
andtransition_bn
respectively.Both
static_bn
andtransition_bn
must contain the expected nodes:For the static network, it must contain the nodes from
[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.For the transition network, it must contain the nodes
[variable_name]_t_0
, and the interface nodes from[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.
- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
static_bn – Static Bayesian network.
transition_bn – Transition Bayesian network.
- class pybnesian.models.DynamicKDENetwork¶
Bases:
pybnesian.models.DynamicBayesianNetwork
This class implements a
DynamicBayesianNetwork
with the typeKDENetworkType
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DynamicKDENetwork, variables: List[str], markovian_order: int) -> None
Initializes the
DynamicKDENetwork
with the givenvariables
andmarkovian_order
. It creates empty static and transition Bayesian networks.- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicKDENetwork, variables: List[str], markovian_order: int, static_bn: pybnesian.models.BayesianNetworkBase, transition_bn: pybnesian.models.ConditionalBayesianNetworkBase) -> None
Initializes the
DynamicKDENetwork
with the givenvariables
andmarkovian_order
. The static and transition Bayesian networks are initialized withstatic_bn
andtransition_bn
respectively.Both
static_bn
andtransition_bn
must contain the expected nodes:For the static network, it must contain the nodes from
[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.For the transition network, it must contain the nodes
[variable_name]_t_0
, and the interface nodes from[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.
- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
static_bn – Static Bayesian network.
transition_bn – Transition Bayesian network.
- class pybnesian.models.DynamicDiscreteBN¶
Bases:
pybnesian.models.DynamicBayesianNetwork
This class implements a
DynamicBayesianNetwork
with the typeDiscreteBN
.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DynamicDiscreteBN, variables: List[str], markovian_order: int) -> None
Initializes the
DynamicDiscreteBN
with the givenvariables
andmarkovian_order
. It creates empty static and transition Bayesian networks.- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicDiscreteBN, variables: List[str], markovian_order: int, static_bn: pybnesian.models.BayesianNetworkBase, transition_bn: pybnesian.models.ConditionalBayesianNetworkBase) -> None
Initializes the
DynamicDiscreteBN
with the givenvariables
andmarkovian_order
. The static and transition Bayesian networks are initialized withstatic_bn
andtransition_bn
respectively.Both
static_bn
andtransition_bn
must contain the expected nodes:For the static network, it must contain the nodes from
[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.For the transition network, it must contain the nodes
[variable_name]_t_0
, and the interface nodes from[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.
- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
static_bn – Static Bayesian network.
transition_bn – Transition Bayesian network.
- class pybnesian.models.DynamicHomogeneousBN¶
Bases:
pybnesian.models.DynamicBayesianNetwork
This class implements an homogeneous dynamic Bayesian network. This dynamic Bayesian network can be used with any
FactorType
. You can set theFactorType
in the constructor.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DynamicHomogeneousBN, factor_type: pybnesian.factors.FactorType, variables: List[str], markovian_order: int) -> None
Initializes the
DynamicHomogeneousBN
offactor_type
with the givenvariables
andmarkovian_order
. It creates empty static and transition Bayesian networks.- Parameters
factor_type –
FactorType
for all the nodes.variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicHomogeneousBN, variables: List[str], markovian_order: int, static_bn: pybnesian.models.BayesianNetworkBase, transition_bn: pybnesian.models.ConditionalBayesianNetworkBase) -> None
Initializes the
DynamicHomogeneousBN
with the givenvariables
andmarkovian_order
. The static and transition Bayesian networks are initialized withstatic_bn
andtransition_bn
respectively.Both
static_bn
andtransition_bn
must contain the expected nodes:For the static network, it must contain the nodes from
[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.For the transition network, it must contain the nodes
[variable_name]_t_0
, and the interface nodes from[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.
The type of
static_bn
andtransition_bn
must beHomogeneousBNType
.- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
static_bn – Static Bayesian network.
transition_bn – Transition Bayesian network.
- class pybnesian.models.DynamicHeterogeneousBN¶
Bases:
pybnesian.models.DynamicBayesianNetwork
This class implements an heterogeneous dynamic Bayesian network. This dynamic Bayesian network accepts a different
FactorType
for each node. You can set the defaultFactorType
in the constructor.- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: pybnesian.models.DynamicHeterogeneousBN, factor_type: pybnesian.factors.FactorType, variables: List[str], markovian_order: int) -> None
Initializes the
DynamicHeterogeneousBN
of defaultfactor_type
with the givenvariables
andmarkovian_order
. It creates empty static and transition Bayesian networks.- Parameters
factor_type – Default
FactorType
for the dynamic Bayesian network.variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicHeterogeneousBN, factor_types: Dict[pyarrow.DataType, pybnesian.factors.FactorType], variables: List[str], markovian_order: int) -> None
Initializes the
DynamicHeterogeneousBN
of different defaultfactor_types
with the givenvariables
andmarkovian_order
. It creates empty static and transition Bayesian networks.- Parameters
factor_types – Default
FactorType
for the Bayesian network for each different data type.variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
__init__(self: pybnesian.models.DynamicHeterogeneousBN, variables: List[str], markovian_order: int, static_bn: pybnesian.models.BayesianNetworkBase, transition_bn: pybnesian.models.ConditionalBayesianNetworkBase) -> None
Initializes the
DynamicHeterogeneousBN
with the givenvariables
andmarkovian_order
. The static and transition Bayesian networks are initialized withstatic_bn
andtransition_bn
respectively.Both
static_bn
andtransition_bn
must contain the expected nodes:For the static network, it must contain the nodes from
[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.For the transition network, it must contain the nodes
[variable_name]_t_0
, and the interface nodes from[variable_name]_t_1
to[variable_name]_t_[markovian_order]
.
The type of
static_bn
andtransition_bn
must beHeterogeneousBNType
.- Parameters
variables – List of variable names.
markovian_order – Markovian order of the dynamic Bayesian network.
static_bn – Static Bayesian network.
transition_bn – Transition Bayesian network.