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 H H A A B B A->B E E A->E C C B->C F F F->B D D C->H C->D 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.72280.2772
1
0.70650.2935
1
0
0.32790.6721
1
0.31060.6894

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.29730.7027
1
0.34600.6540
1
0
0.29700.7030
1
0.34890.6511
1
0
0
0.53150.4685
1
0.58670.4133
1
0
0.53120.4688
1
0.58970.4103
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.29850.7015
1
0.33850.6615
1
0
0.53300.4670
1
0.57850.4215
1
0
0
0.29650.7035
1
0.35640.6436
1
0
0.53060.4694
1
0.59760.4024

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.34920.1949
1
0.20680.2491
1
0
0.12550.5913
1
0.06430.2188
1
0
0
0.48390.1007
1
0.28670.1287
1
0
0.25520.4482
1
0.13080.1658