LoopyGibbsSampling.updateEvidence
- LoopyGibbsSampling.updateEvidence(evidces)
Apply chgEvidence(key,value) for every pairs in evidces (or addEvidence).
- Parameters:
evidces (
dict[str,Union[int,str,list[float]]]orlist[pyagrum.Tensor]) – a dict of “name:evidence” where name is a string (the name of the variable) and evidence is an integer (an index) or a string (a label) or a list of float (a likelihood).- 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.InvalidArgument – If one value has a negative or non-finite value, or is a vector of 0s
pyagrum.FatalError – If one value is soft and the inference is a sampling one (Gibbs, Monte Carlo, Weighted, Importance and their loopy versions)
pyagrum.UndefinedElement – If one node does not belong to the Bayesian network
- Return type:
None
Example
import pyagrum as gum
bn = gum.fastBN("A->B<-C", uniform=True)
ie = gum.LoopyGibbsSampling(bn)
ie.setEvidence({"A": 0})
ie.updateEvidence({"A": 1, "C": 0}) # A changed, C added
ie.makeInference()
ie.posterior("A").tolist()
# [0.0, 1.0]
sorted(ie.softEvidenceNodes()) # sampling accepts hard evidence only
# []
Class