Fragment of Bayesian networks
This class proposes a shallow copy of a part of Bayesian network. It can be used as a Bayesian network for inference algorithms (for instance).
- class pyagrum.BayesNetFragment(bn)
BayesNetFragment represents a part of a Bayesian network (subset of nodes). By default, the arcs and the CPTs are the same as the BN but local CPTs can be build to express different local dependencies. All the non local CPTs are not copied. Therefore a BayesNetFragment is a light object.
- BayesNetFragment(BayesNet bn) -> BayesNetFragment
- Parameters:
bn (
pyagrum.BayesNet) – the bn refered by the fragment
- Parameters:
bn (
IBayesNet)
Methods
Add the listeners in parameters to the list of existing ones. |
|
adjacency matrix from a graph/graphical models |
|
give the set of nodeid of ancestors of a node |
|
Check if the BayesNet is consistent (variables, CPT, …) |
|
If a variable is added to the fragment but not its parents, there is no CPT consistant for this variable. |
|
give the set of nodeid of the children of a node (or of a set of nodes) |
|
Give an instantiation over all the variables of the model |
|
Return the weakly connected components of the graph. |
|
number of connected components |
|
connected components as a dict of sets |
|
Returns the CPT of a variable. |
|
give the set of nodeid of descendants of a node |
|
Returns the dimension (the number of free parameters) in this BayesNet. |
|
Check if there are some variables in the model. |
|
This method is used to set an observation on a quasi-continuous variables ( |
|
This method is used to set an observation on a quasi-continuous variables ( |
|
This method is used to set an observation on a quasi-continuous variables ( |
|
This method is used to set an observation on a quasi-continuous variables ( |
|
Check if a node with this name or id exists |
|
Check if an arc exists |
|
Check whether a property key exists in the model’s metadata. |
|
give the set of parents of a node and the node |
|
Returns a variable’s id given its name in the graph. |
|
List of ids for a list of names of variables in the model |
|
The ids of nodes given by their names, in a container of the same type. |
|
Add the variable and all its ascendants in the fragment. |
|
Install a local CPT for a node. |
|
Install a local marginal for a node. |
|
Add a node to the fragment. |
|
check if nodes X and nodes Y are independent given nodes Z |
|
Check if a node is in the fragment |
|
returns the log10 of the domain size of the model defined as the product of the domain sizes of the variables in the model. |
|
Returns the memory footprint in bytes of the Bayesian network. |
|
Returns, given one or many targets and a list of variables, the minimal set of those needed to calculate the target/targets. |
|
Returns the moral graph of the BayesNet, formed by adding edges between all pairs of nodes that have a common child, and then making all edges in the graph undirected. |
|
build a UndiGraph by moralizing the Ancestral Graph of a list of nodes |
|
Set of names of variables in the model |
|
The names of nodes given by their ids, in a container of the same type. |
|
Set of ids for a list of names of variables in the model |
|
give the set of nodeid of the parents of a node (or of a set of nodes) |
|
Return the keys of all metadata properties of the model. |
|
Returns the value associated to this property. |
|
Returns the value associated to this property or the default value if there is no such property. |
|
Create or change the couple (name,value) in the properties. |
|
Return a human-readable string summarising the space complexity of a graphical model. |
|
Create a BayesNet from a fragment. |
|
Remove a local CPT. |
|
Remove a node from the fragment. |
|
Update the model’s built-in metadata (version, creation date, last modification date). |
|
Return the variables of the model: all of them, or those corresponding to a list of names or to a set of node ids. |