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 E E A->E B B A->B D D F F F->B H H E->D C C C->D C->H B->C

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.71380.2862
1
0.68080.3192
1
0
0.30470.6953
1
0.27270.7273

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.87220.1278
1
0.97380.0262
1
0
0.88650.1135
1
0.97670.0233
1
0
0
0.53720.4628
1
0.86360.1364
1
0
0.57060.4294
1
0.87700.1230
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.90660.0934
1
0.98830.0117
1
0
0.62270.3773
1
0.93480.0652
1
0
0
0.79160.2084
1
0.96930.0307
1
0
0.39250.6075
1
0.84280.1572

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.32060.0245
1
0.53380.1210
1
0
0.41370.3178
1
0.09420.1744
1
0
0
0.18750.0843
1
0.31210.4161
1
0
0.12160.5493
1
0.02770.3014