Inference for Influence Diagram
- 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)
Returns maximum expected utility obtained from inference.
- Raises:
pyAgrum.OperationNotAllowed – If no inference have yet been made
- Return type:
object
- 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)
- Return type:
None
- 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()
- Return type:
None
- eraseAllEvidence()
Remove all evidence.
- Return type:
None
- 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()
- Returns:
the set of nodes with hard evidence
- Return type:
set
- 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)
- 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()
- Return type:
bool
- 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()
Returns a constant reference over the InfluenceDiagram on which this class work.
- Returns:
the InfluenceDiagram on which this class work
- Return type:
- isSolvable()
check wether the influence diagram is solvable or not
- Returns:
True if the influence diagram is solvable
- Return type:
bool
- junctionTree()
- Returns:
the current junction tree
- Return type:
- makeInference()
Perform the heavy computations needed to compute the optimal decisions.
- Return type:
None
- 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()
- Returns:
the number of evidence entered into the Bayesian network
- Return type:
int
- nbrHardEvidence()
- Returns:
the number of hard evidence entered into the Bayesian network
- Return type:
int
- nbrSoftEvidence()
- Returns:
the number of soft evidence entered into the Bayesian network
- Return type:
int
- 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:
- pyAgrum.InvalidNode
If node given in parmaeter is not a decision node
- 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:
- 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:
- reducedGraph()
Returns the DAG build to solve the influence diagram.
- Returns:
a copy of the reduced graph
- Return type:
- reducedLIMID()
Returns the (reduced) LIMID build to solve the influence diagram.
- Returns:
a copy of the reduced influence Diagram (LIMID)
- Return type:
- reversePartialOrder()
- 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()
- Return type:
object
- 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