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

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.58080.4192
1
0.63300.3670
1
0
0.47740.5226
1
0.53210.4679

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.41220.5878
1
0.53870.4613
1
0
0.40610.5939
1
0.54140.4586
1
0
0
0.69190.3081
1
0.78900.2110
1
0
0.68640.3136
1
0.79070.2093
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.43070.5693
1
0.53110.4689
1
0
0.70780.2922
1
0.78380.2162
1
0
0
0.38860.6114
1
0.54930.4507
1
0
0.67050.3295
1
0.79600.2040

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.34240.1607
1
0.29660.2003
1
0
0.21970.2418
1
0.31890.2195
1
0
0
0.45540.0668
1
0.39460.0832
1
0
0.32190.1107
1
0.46700.1004