Inference for Influence Diagram

class pyagrum.ShaferShenoyLIMIDInference(infDiag)
Section titled “class pyagrum.ShaferShenoyLIMIDInference(infDiag)”This inference considers the provided model as a LIMID rather than an influence diagram. It is an optimized implementation of the LIMID resolution algorithm. However an inference on a classical influence diagram can be performed by adding a assumption of the existence of the sequence of decision nodes to be solved, which also implies that the decision choices can have an impact on the rest of the sequence (Non Forgetting Assumption, cf. pyagrum.ShaferShenoyLIMIDInference.addNoForgettingAssumption).
- Parameters:
infDiag (
InfluenceDiagram)
MEU(*args)
Section titled “MEU(*args)”Returns maximum expected utility obtained from inference.
- Raises: pyagrum.OperationNotAllowed – If no inference have yet been made
- Return type:
object
addEvidence(*args)
Section titled “addEvidence(*args)”Adds a new evidence on a node (might be soft or hard).
- Parameters:
- id (int) – a node Id
- nodeName (int) – a node name
- val – (int) a node value
- val – (str) the label of the node value
- vals (list) – a list of values
- Raises:
- pyagrum.InvalidArgument – If the node already has an evidence
- pyagrum.InvalidArgument – If val is not a value for the node
- pyagrum.InvalidArgument – If the size of vals is different from the domain side of the node
- pyagrum.FatalError – If vals is a vector of 0s
- pyagrum.UndefinedElement – If the node does not belong to the Bayesian network
- Return type:
None
addNoForgettingAssumption(*args)
Section titled “addNoForgettingAssumption(*args)”- Return type:
None
chgEvidence(*args)
Section titled “chgEvidence(*args)”Change the value of an already existing evidence on a node (might be soft or hard).
- Parameters:
- id (int) – a node Id
- nodeName (int) – a node name
- val (intstr) – a node value or the label of the node value
- vals (List [**float ]) – a list of values
- Raises:
- pyagrum.InvalidArgument – If the node does not already have an evidence
- pyagrum.InvalidArgument – If val is not a value for the node
- pyagrum.InvalidArgument – If the size of vals is different from the domain side of the node
- pyagrum.FatalError – If vals is a vector of 0s
- pyagrum.UndefinedElement – If the node does not belong to the Bayesian network
- Return type:
None
clear()
Section titled “clear()”- Return type:
None
eraseAllEvidence()
Section titled “eraseAllEvidence()”Remove all evidence.
- Return type:
None
eraseEvidence(*args)
Section titled “eraseEvidence(*args)”Remove the evidence, if any, corresponding to the node Id or name.
- Parameters:
- id (int) – a node Id
- nodeName (int) – a node name
- Raises: pyagrum.IndexError – If the node does not belong to the Bayesian network
- Return type:
None
hardEvidenceNodes()
Section titled “hardEvidenceNodes()”- Returns: the set of nodes with hard evidence
- Return type: set
hasEvidence(*args)
Section titled “hasEvidence(*args)”- Parameters:
- id (int) – a node Id
- nodeName (str) – a node name
- Returns: True if some node(s) (or the one in parameters) have received evidence
- Return type: bool
- Raises: pyagrum.IndexError – If the node does not belong to the Bayesian network
hasHardEvidence(nodeName)
Section titled “hasHardEvidence(nodeName)”- Parameters:
- id (int) – a node Id
- nodeName (str) – a node name
- Returns: True if node has received a hard evidence
- Return type: bool
- Raises: pyagrum.IndexError – If the node does not belong to the Bayesian network
hasNoForgettingAssumption()
Section titled “hasNoForgettingAssumption()”- Return type:
bool
hasSoftEvidence(*args)
Section titled “hasSoftEvidence(*args)”- Parameters:
- id (int) – a node Id
- nodeName (str) – a node name
- Returns: True if node has received a soft evidence
- Return type: bool
- Raises: pyagrum.IndexError – If the node does not belong to the Bayesian network
influenceDiagram()
Section titled “influenceDiagram()”Returns a constant reference over the InfluenceDiagram on which this class work.
- Returns: the InfluenceDiagram on which this class work
- Return type: pyagrum.InfluenceDiagram
isSolvable()
Section titled “isSolvable()”check wether the influence diagram is solvable or not
- Returns: True if the influence diagram is solvable
- Return type: bool
junctionTree()
Section titled “junctionTree()”- Returns: the current junction tree
- Return type: pyagrum.CliqueGraph
makeInference()
Section titled “makeInference()”Perform the heavy computations needed to compute the optimal decisions.
- Return type:
None
meanVar(*args)
Section titled “meanVar(*args)”- Parameters:
- id (int) – a node Id
- nodeName (str) – a node name
- Returns: a dictionary with the mean and variance of the node (after the inference)
- Return type: dict[str, float]
nbrEvidence()
Section titled “nbrEvidence()”- Returns: the number of evidence entered into the Bayesian network
- Return type: int
nbrHardEvidence()
Section titled “nbrHardEvidence()”- Returns: the number of hard evidence entered into the Bayesian network
- Return type: int
nbrSoftEvidence()
Section titled “nbrSoftEvidence()”- Returns: the number of soft evidence entered into the Bayesian network
- Return type: int
optimalDecision(*args)
Section titled “optimalDecision(*args)”Returns best choice for decision variable given in parameter ( based upon MEU criteria )
- Parameters: decisionId (int ,**str) – the id or name of the decision variable
- Raises: pyagrum.OperationNotAllowed – If no inference have yet been made
- Return type:
Tensor
pyagrum.InvalidNode : If node given in parmaeter is not a decision node
posterior(*args)
Section titled “posterior(*args)”Returns the posterior of a chance or a decision node (after optimisation).
- Parameters:
- var (int) – the node Id of the node for which we need a posterior probability
- nodeName (str) – the node name of the node for which we need a posterior probability
- Returns: a const ref to the posterior probability of the node
- Return type: pyagrum.Tensor
posteriorUtility(*args)
Section titled “posteriorUtility(*args)”Returns the posterior utiliyt of a utility node (after optimisation) depending on decision nodes, if any.
- Parameters:
- var (int) – the node Id of the node for which we need a posterior probability
- nodeName (str) – the node name of the node for which we need a posterior probability
- Returns: a const ref to the posterior utility of the utility node
- Return type: pyagrum.Tensor
reducedGraph()
Section titled “reducedGraph()”Returns the DAG build to solve the influence diagram.
- Returns: a copy of the reduced graph
- Return type: pyagrum.DAG
reducedLIMID()
Section titled “reducedLIMID()”Returns the (reduced) LIMID build to solve the influence diagram.
- Returns: a copy of the reduced influence Diagram (LIMID)
- Return type: pyagrum.InfluenceDiagram
reversePartialOrder()
Section titled “reversePartialOrder()”setEvidence(evidces)
Section titled “setEvidence(evidces)”Erase all the evidences and apply addEvidence(key,value) for every pairs in evidces.
- Parameters: evidces (dict) – a dict of evidences
- Raises:
- pyagrum.InvalidArgument – If one value is not a value for the node
- pyagrum.InvalidArgument – If the size of a value is different from the domain side of the node
- pyagrum.FatalError – If one value is a vector of 0s
- pyagrum.UndefinedElement – If one node does not belong to the influence diagram
softEvidenceNodes()
Section titled “softEvidenceNodes()”- Return type:
object
updateEvidence(evidces)
Section titled “updateEvidence(evidces)”Apply chgEvidence(key,value) for every pairs in evidces (or addEvidence).
- Parameters: evidces (dict) – a dict of evidences
- Raises:
- pyagrum.InvalidArgument – If one value is not a value for the node
- pyagrum.InvalidArgument – If the size of a value is different from the domain side of the node
- pyagrum.FatalError – If one value is a vector of 0s
- pyagrum.UndefinedElement – If one node does not belong to the Bayesian network