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 D D B B C C B->C A A A->B E E A->E E->D F F F->B C->H C->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.68580.3142
1
0.58350.4165
1
0
0.38220.6178
1
0.28420.7158

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.91220.0878
1
0.94230.0577
1
0
0.92240.0776
1
0.93830.0617
1
0
0
0.49800.5020
1
0.60950.3905
1
0
0.53160.4684
1
0.59220.4078
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.92430.0757
1
0.93630.0637
1
0
0.53840.4616
1
0.58380.4162
1
0
0
0.89150.1085
1
0.94420.0558
1
0
0.43970.5603
1
0.61790.3821

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.04290.0126
1
0.83230.1122
1
0
0.15690.0418
1
0.50850.2928
1
0
0
0.01970.0605
1
0.38150.5383
1
0
0.03760.1051
1
0.12200.7353