WeightedSampling.makeInference
- WeightedSampling.makeInference()
Perform the heavy computations needed to compute the targets’ posteriors
In a Junction tree propagation scheme, for instance, the heavy computations are those of the messages sent in the JT. This is precisely what makeInference should compute. Later, the computations of the posteriors can be done ‘lightly’ by multiplying and projecting those messages.
- Return type:
None
Example
import pyagrum as gum
bn = gum.fastBN("A->B<-C", uniform=True)
ie = gum.WeightedSampling(bn)
ie.setEvidence({"A": 1})
ie.setEpsilon(1e-10)
ie.setMaxIter(5000)
ie.makeInference()
ie.messageApproximationScheme()
# 'stopped with max iteration=5000'
exact = gum.LazyPropagation(bn)
exact.setEvidence({"A": 1})
exact.makeInference()
abs(ie.posterior("B")[1] - exact.posterior("B")[1]) < 0.05 # an approximation of the exact posterior
# True
Class
Overridden in