Some other features in Bayesian inference

Creative Commons License

aGrUM

interactive online version

Lazy Propagation uses a secondary structure called the “Junction Tree” to perform the inference.

In [1]:
import pyAgrum as gum
import pyAgrum.lib.notebook as gnb

bn=gum.loadBN("res/alarm.dsl")
gnb.showJunctionTreeMap(bn);
../_images/notebooks_43-Inference_LazyPropagationAdvancedFeatures_3_0.svg

But this junction tree can be transformed to build different probabilistic queries.

In [2]:
bn=gum.fastBN("A->B->C->D;A->E->D;F->B;C->H")
ie=gum.LazyPropagation(bn)
bn
Out[2]:
G A A B B A->B E E A->E H H F F F->B C C C->H D D C->D B->C E->D

Evidence impact

Evidence Impact allows the user to analyze the effect of any variables on any other variables

In [3]:
ie.evidenceImpact("B",["A","H"])
Out[3]:
B
A
H
0
1
0
0
0.68720.3128
1
0.72830.2717
1
0
0.85490.1451
1
0.87790.1221

Evidence impact is able to find the minimum set of variables which effectively conditions the analyzed variable

In [4]:
ie.evidenceImpact("E",["A","F","B","D"]) # {A,D,B} d-separates E and F
Out[4]:
E
A
B
D
0
1
0
0
0
0.98190.0181
1
0.97340.0266
1
0
0.98210.0179
1
0.97740.0226
1
0
0
0.22440.7756
1
0.16320.8368
1
0
0.22680.7732
1
0.18770.8123
In [5]:
ie.evidenceImpact("E",["A","B","C","D","F"]) # {A,C,D} d-separates E and {B,F}
Out[5]:
E
C
A
D
0
1
0
0
0
0.98340.0166
1
0.97920.0208
1
0
0.24060.7594
1
0.20050.7995
1
0
0
0.98180.0182
1
0.90600.0940
1
0
0.22330.7767
1
0.04890.9511

Evidence Joint Impact

In [6]:
ie.evidenceJointImpact(["A","F"],["B","C","D","E","H"]) # {B,E} d-separates [A,F] and [C,D,H]
Out[6]:
A
E
B
F
0
1
0
0
0
0.17560.0200
1
0.71340.0910
1
0
0.30090.0256
1
0.65460.0189
1
0
0
0.00810.1730
1
0.03290.7861
1
0
0.03230.5160
1
0.07040.3813