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

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.53710.4629
1
0.62660.3734
1
0
0.62830.3717
1
0.70970.2903

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.42960.5704
1
0.13080.8692
1
0
0.35000.6500
1
0.13890.8611
1
0
0
0.59530.4047
1
0.22720.7728
1
0
0.51260.4874
1
0.23970.7603
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.30860.6914
1
0.14820.8518
1
0
0.46580.5342
1
0.25370.7463
1
0
0
0.44620.5538
1
0.12980.8702
1
0
0.61150.3885
1
0.22560.7744

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.32950.4631
1
0.15220.0552
1
0
0.54160.2587
1
0.03350.1662
1
0
0
0.44110.3174
1
0.20370.0378
1
0
0.68330.1671
1
0.04230.1073