mbdlyb.formalisms.bayesnet.reasoner =================================== .. py:module:: mbdlyb.formalisms.bayesnet.reasoner .. autoapi-nested-parse:: Bayesian Network inference engine and reasoning operations. This module provides inference capabilities for Bayesian networks, including exact and approximate inference methods, d-separation analysis, and information- theoretic computations such as entropy and conditional entropy. Classes: BayesNetReasoner: The main inference engine for Bayesian networks. Classes ------- .. autoapisummary:: mbdlyb.formalisms.bayesnet.reasoner.BayesNetReasoner Module Contents --------------- .. py:class:: BayesNetReasoner(net: mbdlyb.formalisms.bayesnet.base.BayesNet, exact: bool = True) Bases: :py:obj:`mbdlyb.MBDReasoner` Inference engine for Bayesian networks. Supports both exact inference (using lazy propagation) and approximate inference (using loopy belief propagation). Provides methods for inference, d-separation analysis, entropy computation, and conditional independence testing. :ivar _engine: The inference engine class (LazyPropagation or LoopyBeliefPropagation). :ivar _net: The BayesNet instance being reasoned over. :ivar _bn: The underlying pyAgrum BayesNet structure. :ivar _ie: The pyAgrum inference engine instance. .. py:method:: conditional_entropy(y: set[mbdlyb.MBDNode], x: set[mbdlyb.MBDNode], evidence: Optional[mbdlyb.Evidence] = None) -> float Compute the conditional entropy H(Y|X). Calculates the entropy of variable set y given variable set x, optionally conditioned on additional evidence. :param y: The set of nodes for which to compute entropy. :param x: The conditioning variable set. :param evidence: Optional evidence to apply before computation. :returns: The conditional entropy H(Y|X) in bits. .. py:method:: entropy(y: set[mbdlyb.MBDNode], evidence: Optional[mbdlyb.Evidence] = None) -> float Compute the entropy H(Y) of a set of nodes. Calculates the Shannon entropy of the joint distribution of a set of variables, optionally conditioned on evidence. :param y: The set of nodes for which to compute entropy. :param evidence: Optional evidence to apply before computation. :returns: The entropy H(Y) in bits. .. py:method:: infer(*targets: mbdlyb.MBDNode) -> mbdlyb.reasoner.T_POSTERIORS Perform inference on target nodes given current evidence. Computes the posterior probability distributions for the specified target nodes given the current evidence set in the reasoner. :param \*targets: One or more MBDNode instances to compute posteriors for. :returns: A dictionary mapping each target node to a dictionary of its states and their posterior probabilities. .. py:method:: init() Initialize the inference engine. Converts the abstract Bayesian network to a pyAgrum BayesNet and creates the configured inference engine instance. For approximate inference, sets convergence parameters. .. py:method:: is_d_separated(y: Union[mbdlyb.MBDNode, set[mbdlyb.MBDNode]], x: Union[mbdlyb.MBDNode, set[mbdlyb.MBDNode]], z: Optional[Union[mbdlyb.MBDNode, set[mbdlyb.MBDNode], mbdlyb.Evidence]] = None) Test d-separation between two sets of nodes. Determines whether y and x are d-separated (conditionally independent) given the conditioning set z in the network's DAG structure. :param y: A node or set of nodes to test for independence. :param x: A node or set of nodes to test for independence. :param z: An optional conditioning set (nodes or Evidence). If None, tests unconditional independence. :returns: True if y and x are d-separated given z; False otherwise.