mbdlyb.formalisms.markovnet.reasoner ==================================== .. py:module:: mbdlyb.formalisms.markovnet.reasoner .. autoapi-nested-parse:: Markov Network inference engine and reasoning operations. This module provides inference capabilities for Markov networks, including exact inference using belief propagation algorithms and information-theoretic computations such as entropy and conditional entropy. Classes: MarkovNetReasoner: The main inference engine for Markov networks. Classes ------- .. autoapisummary:: mbdlyb.formalisms.markovnet.reasoner.MarkovNetReasoner Module Contents --------------- .. py:class:: MarkovNetReasoner(net: mbdlyb.formalisms.markovnet.base.MarkovNet, **kwargs) Bases: :py:obj:`mbdlyb.MBDReasoner` Inference engine for Markov networks (undirected graphical models). Supports exact inference using Shafer-Shenoy message passing algorithm. Provides methods for inference, entropy computation, and conditional entropy calculations on Markov random fields. :ivar _net: The MarkovNet instance being reasoned over. :ivar _mn: The underlying pyAgrum MarkovRandomField structure. :ivar _ie: The pyAgrum inference engine instance (ShaferShenoyMRFInference). .. 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 Markov network to a pyAgrum MarkovRandomField and creates the Shafer-Shenoy inference engine instance.