probabilistic_model.bayesian_network.bayesian_network#
Classes#
A node in the bayesian network |
|
Class for Bayesian Networks that are rooted, tree shaped and have univariate inner nodes. |
|
A node in the bayesian network |
|
Conditional probability distribution for Bayesian Network nodes given their parents. |
|
Conditional probability distribution represented as Circuit for Bayesian Network nodes given their parents. |
Module Contents#
- class probabilistic_model.bayesian_network.bayesian_network.Node#
A node in the bayesian network These distributions do not inherit from probabilistic models, since inference in Bayesian Networks is intractable. For inference, convert the bayesian network to a probabilistic circuit.
- bayesian_network: typing_extensions.Optional[BayesianNetwork] = None#
The bayesian network this node is part of.
- index: typing_extensions.Optional[int] = None#
The index of the node in the graph of its circuit.
- product_units: typing_extensions.Dict[typing_extensions.Any, probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProductUnit]#
A dictionary from states of the variable to product units. Only needed during conversion to probabilistic circuits.
- __post_init__()#
- __hash__()#
- property variables: typing_extensions.Tuple[random_events.variable.Variable, Ellipsis]#
- Abstractmethod:
- abstract as_probabilistic_circuit(result: probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit)#
Add this node to the probabilistic circuit. This also creates all the edges implied by this node.
- Parameters:
result – The probabilistic circuit to add the nodes to.
- class probabilistic_model.bayesian_network.bayesian_network.BayesianNetwork#
Class for Bayesian Networks that are rooted, tree shaped and have univariate inner nodes. This class does not inherit from ProbabilisticModel since it cannot perform inference. Bayesian Networks can be converted to a probabilistic circuit which can perform inference.
- __len__()#
Return the number of nodes in the graph.
- Returns:
The number of nodes in the graph.
- __iter__()#
Return an iterator over the nodes in the graph.
- Returns:
An iterator over the nodes in the graph.
- is_valid() bool#
Check if this graph is:
acyclic
connected
- Returns:
True if the graph is valid, False otherwise.
- in_edges(node: Node) typing_extensions.List[typing_extensions.Tuple[Node, Node, typing_extensions.Optional[float]]]#
- nodes() typing_extensions.List[Node]#
Return an iterator over the nodes.
- Returns:
An iterator over the nodes.
- property root: Root#
The root of the circuit is the node with in-degree 0. This is the output node, that will perform the final computation.
- Returns:
The root of the circuit.
- abstract __eq__(other: typing_extensions.Self)#
- __repr__()#
- as_probabilistic_circuit() probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit#
Convert the bayesian network to a probabilistic circuit.
- Returns:
The probabilistic circuit.
- plot()#
- class probabilistic_model.bayesian_network.bayesian_network.Root#
Bases:
NodeA node in the bayesian network These distributions do not inherit from probabilistic models, since inference in Bayesian Networks is intractable. For inference, convert the bayesian network to a probabilistic circuit.
- distribution: probabilistic_model.distributions.SymbolicDistribution#
- root: typing_extensions.Optional[probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.SumUnit] = None#
The root of the circuit that is generated by the as_probabilistic_circuit method.
- __hash__#
- property variable: random_events.variable.Symbolic#
- property variables: typing_extensions.Tuple[random_events.variable.Variable, Ellipsis]#
- as_probabilistic_circuit(result: probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit)#
Add this node to the probabilistic circuit. This also creates all the edges implied by this node.
- Parameters:
result – The probabilistic circuit to add the nodes to.
- class probabilistic_model.bayesian_network.bayesian_network.ConditionalProbabilityTable#
Bases:
NodeConditional probability distribution for Bayesian Network nodes given their parents. The parent in this case must be exactly one node.
- conditional_probability_distributions: typing_extensions.Dict[typing_extensions.Any, probabilistic_model.distributions.SymbolicDistribution]#
- __hash__#
- property variable: random_events.variable.Symbolic#
- property variables: typing_extensions.Tuple[random_events.variable.Variable, Ellipsis]#
- __repr__()#
- to_tabulate() typing_extensions.List[typing_extensions.List[str]]#
Tabulate the truncated probability table.
- Returns:
A table with the truncated probability table that can be printed using tabulate.
- as_probabilistic_circuit(result: probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit)#
Add this node to the probabilistic circuit. This also creates all the edges implied by this node.
- Parameters:
result – The probabilistic circuit to add the nodes to.
- class probabilistic_model.bayesian_network.bayesian_network.ConditionalProbabilisticCircuit#
Bases:
NodeConditional probability distribution represented as Circuit for Bayesian Network nodes given their parents.
- conditional_probability_distributions: typing_extensions.Dict[int, probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit]#
- __hash__#
- property parent: ConditionalProbabilityTable#
- property variables: typing_extensions.Tuple[random_events.variable.Variable, Ellipsis]#
- __repr__()#
- as_probabilistic_circuit(result: probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit)#
Add this node to the probabilistic circuit. This also creates all the edges implied by this node.
- Parameters:
result – The probabilistic circuit to add the nodes to.