mbdlyb.reasoner
Abstract base class for diagnostic reasoning engines.
The MBDReasoner class provides the interface and base functionality for different reasoning paradigms (e.g., Bayesian Networks, Markov Networks) used to perform probabilistic inference on MBD models.
Attributes
Mapping from nodes to their most probable state. |
|
A node and its assigned value/state. |
|
Mapping of a node's state->probability distribution. |
|
Mapping from nodes to state->probability distributions |
Classes
Abstract base class for Model-Based Diagnostic reasoners. |
Module Contents
- class mbdlyb.reasoner.MBDReasoner(net: mbdlyb.MBDNet, **kwargs)
Bases:
abc.ABCAbstract base class for Model-Based Diagnostic reasoners.
An MBDReasoner implements the reasoning algorithm for a specific formalism (Bayesian networks, Markov networks, etc.) and provides methods for inference, evidence management, and information-theoretic queries.
- Variables:
- add_targets(*targets: mbdlyb.MBDNode, reset=False)
Add nodes to the target set for inference.
- Parameters:
*targets (MBDNode) – Nodes to add as targets.
reset (bool) – If True, clear existing targets before adding. Default is False.
- abstractmethod conditional_entropy(y: set[mbdlyb.MBDNode], x: set[mbdlyb.MBDNode], evidence: mbdlyb.Evidence | None = None) float
Compute conditional entropy H(Y|X) given evidence.
Measures the uncertainty in Y given X, useful for information-based diagnostics and decision-making.
- drop_targets(*targets: mbdlyb.MBDNode)
Remove nodes from the target set, or reset to all nodes if no targets specified.
- Parameters:
*targets (MBDNode) – Specific nodes to remove from targets. If empty, targets are reset to all flat nodes in the network.
- abstractmethod entropy(y: set[mbdlyb.MBDNode], evidence: mbdlyb.Evidence | None = None) float
Compute entropy H(Y) given evidence.
Measures the uncertainty in a set of variables given current evidence, useful for assessing confidence in diagnostic conclusions.
- abstractmethod infer(*targets: mbdlyb.MBDNode) T_POSTERIORS
Perform inference to compute marginal probabilities for target nodes.
- Parameters:
*targets (MBDNode) – Nodes to query. If empty, uses the current target set.
- Returns:
Mapping from target nodes to dictionaries of state->probability distributions.
- Return type:
- infer_discrete(*targets: mbdlyb.MBDNode) T_DISCRETE_BELIEFS
Perform inference and return discrete probability distributions.
- Parameters:
*targets (MBDNode) – Nodes to query. If empty, uses the current target set.
- Returns:
Mapping from target nodes to their most probable state.
- Return type:
- abstractmethod init()
Initialize the reasoner’s internal state for a network.
Called to prepare the reasoner after construction, typically compiling the network or building internal data structures.
Subclasses must implement this to perform formalism-specific initialization.
- reset()
Reset the reasoner to initial state, clearing evidence and targets.
Clears all evidence and sets targets to all flat nodes in the network.
- property evidence: mbdlyb.Evidence
Get the current evidence.
- Returns:
The evidence container.
- Return type:
- type mbdlyb.reasoner.T_DISCRETE_BELIEFS = dict[MBDNode, Hashable]
Mapping from nodes to their most probable state.
- type mbdlyb.reasoner.T_NODE_VALUATION = tuple[MBDNode, Hashable]
A node and its assigned value/state.
- type mbdlyb.reasoner.T_POSTERIOR = dict[Hashable, float]
Mapping of a node’s state->probability distribution.
- type mbdlyb.reasoner.T_POSTERIORS = dict[MBDNode, T_POSTERIOR]
Mapping from nodes to state->probability distributions