Tutorial 7

Tutorial 7
Forward sampling, AgenaRisk and Quickscore
Tal Shor
Forward sampling
Using AgenaRisk, Fitting data to a network, and proof
Forward sampling reminder
Un-Weighted version
counter = 0
for i=[1,M]:
s = sample from P(S)
r = sample from P(R)
h = sample from P(H|S=s,R=r)
e = sample from P(E|S=s)
g = sample from P(G|H=h,E=e)
If (condition holds - g=1)
counter++
R
Weighted version
counter = 0
for i=[1,M]:
w=1
S = sample from P(S)
R = sample from P(R)
H = sample from P(H|S,R)
E = set to true. w *= P(E=1|S=s)
G = sample from P(G|H,E)
If (condition holds - g=1)
counter += w
Output = counter / M
S
H
E
G
Forward sampling proof (for the specific BN)
β€’ Let 𝑀 be the weight function, so 𝑀 𝑠 = 𝑃 𝐸 = 1 𝑆 = 𝑠
β€’ So the mean of 𝑀 is
E w(s) = P(E=1|S=0)P(S=0)+P(E=1|S=1)P(S=1)=P(E=1)
β€’ Our counter would be the function
times the condition passed
𝑁𝑀
𝑖
such that 𝑁 is the number of
𝑁
𝐸 π‘π‘œπ‘’π‘›π‘‘π‘’π‘Ÿ = 𝐸[𝐸[
𝑀𝑖 𝑁 = 𝑛 ] = 𝐸[𝑁 β‹… 𝑃(𝐸 = 1)] =
𝑀 β‹… 𝑃 𝐺 = 1 𝐸 = 1 β‹… 𝑃 𝐸 = 1 = 𝑀 β‹… 𝑃(𝐺 = 1, 𝐸 = 1)
Quickscore
A rundown of the paper :
A Tractable Inference Algorithm for Diagnosing Multiple Diseases
Definitions
β€’ We will be looking at bi-partite graphs that represents diseases and symptoms.
β€’ 𝑑 would symbolize a disease node, where 𝑑+ denotes the present of that
particular disease, and π‘‘βˆ’ denotes it’s absence.
β€’ 𝑓 refers to symptoms, 𝑓 + , 𝑓 βˆ’ denotes present and absence of that symptom.
β€’ π·π‘˜ would be some instance of all diseases,
such that π·π‘˜+ are all the present diseases,
and π·π‘˜βˆ’ are all those who are absence.
Assumptions
1. Diseases are marginally independent, and symptoms are
conditionally independent.
2. If a disease is absence, it cannot cause any symptom.
3. Knowing whether or not 𝑑𝑖 causes 𝑓 to be present, does not effect
the probability that 𝑑2 causes 𝑓.
Assumptions (2)
β€’ Those assumptions hold under a new model, where for each 𝑑𝑖 , 𝑑𝑗 , 𝑓
we have the subgraph that includes
causality nodes for each disease followed by an OR gate.
β€’ The lack of edge between the oval nodes is the
embodiment of our 3rd assumption and this condition
independence is called casual independence
Probability of a symptom
β€’ Under this model, we’ll denote
𝑝 𝑓 + π‘œπ‘›π‘™π‘¦ 𝑑𝑖 π‘π‘œπ‘ π‘–π‘‘π‘–π‘£π‘’ = 𝑝𝑖 β‡’ 𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖 π‘π‘œπ‘ π‘–π‘‘π‘–π‘£π‘’ = 1 βˆ’ 𝑝𝑖
β€’ Due to the or gate we can see that
𝑝 𝑓 βˆ’ π·π‘˜ =
𝑝(𝑓 βˆ’ |π‘œπ‘›π‘™π‘¦ 𝑑𝑖 )
π‘‘βˆˆπ·π‘˜+
Therefore
3 𝑝 π‘“βˆ’ =
𝑝 𝑓 βˆ’ π·π‘˜ 𝑝 π·π‘˜ =
𝑝(𝑓 βˆ’ |π‘œπ‘›π‘™π‘¦ 𝑑𝑖 ) 𝑝 π·π‘˜
π·π‘˜ ∈𝐷 π‘‘βˆˆπ·π‘˜+
π·π‘˜ ∈𝐷
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖
=
π·π‘˜ ∈𝐷 π‘‘βˆˆπ·π‘˜+
𝑝 𝑑+
π‘‘βˆˆD+
π‘˜
𝑝 π‘‘βˆ’
π‘‘βˆˆDβˆ’
π‘˜
3 ⇔ (5) proof
𝑛
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖 𝑝 𝑑𝑖+ + 𝑝 π‘‘π‘–βˆ’
𝑖=1
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖 𝑝 𝑑𝑖+
=
π‘†π‘†βŠ† 𝑛
π‘–βˆˆπ‘†
π‘–βˆ‰π‘†
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑
=
π·π‘˜ ∈𝐷 π‘‘βˆˆπ·π‘˜+
𝑝 π‘‘π‘–βˆ’
𝑝 𝑑 = p π‘“βˆ’
𝑝 𝑑
π‘‘βˆˆπ·π‘˜+
π‘‘βˆˆπ·π‘˜βˆ’
Implications of 3 ⇔ (5)
β€’ Now, we don’tβˆ’ have to search every possible disease instance (2𝑛 ), we can
compute 𝑝(𝑓 ) in 𝑂(𝑛).
β€’ Since our symptoms are
conditionally independent, we get that
𝑛
6 𝑝 πΉβˆ’ =
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖
𝑖=1
𝑝 𝑑𝑖+ + 𝑝 π‘‘π‘–βˆ’
π‘“βˆˆπΉ βˆ’
β€’ Under some other, unspecified calculations,
we can derive that
𝑛
10 𝑝 𝐹
+
=
βˆ’1
𝐹 β€² ∈2𝐹
+
𝐹′
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖
𝑖=1
π‘“βˆˆπΉ β€²
𝑝 𝑑𝑖+ + 𝑝 π‘‘π‘–βˆ’
Quickscore final formula
β€’ The stark difference in complexity between positive
symptoms and
+
negative ones, is quite obvious due to 𝐹 β€² ∈ 2𝐹 .
11 𝑝 𝐹 βˆ’ , 𝐹 +
=
βˆ’1
𝐹 β€² ∈2𝐹
+
𝑛
𝐹′
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖
𝑖=1
𝑝 𝑑𝑖+ + 𝑝 π‘‘π‘–βˆ’
π‘“βˆˆπΉ β€² βˆͺ𝐹 βˆ’
βˆ’ , 𝐹 + |𝑑 𝑝(𝑑 )
𝑝
𝐹
𝑖
𝑖
+
βˆ’
12 𝑝 𝑑𝑖 𝐹 , 𝐹 =
𝑝 πΉβˆ’, 𝐹+
Where 𝑝 𝐹 βˆ’ , 𝐹 + |𝑑𝑖 can be calculated by setting 𝑝 𝑑𝑖+ = 1 in (11)
Example (copy to whiteboard)
Figure 4.37 in the textbook at chapter 4.5.3
.01
.1
𝐷1
𝐷2
.1
.8
.2
.2
𝐷3
.9
.1
.5
.2
𝐷4
.7
.8
.2
𝑀1
𝑀2
𝑀3
𝑀4
+
-
+
-
Quicksort calculation
𝑛
βˆ’1
𝐹 β€² ∈2𝐹
+
𝐹′
𝑝 𝑓 βˆ’ π‘œπ‘›π‘™π‘¦ 𝑑𝑖
𝑖=1
𝑝 𝑑𝑖+ + 𝑝 π‘‘π‘–βˆ’
π‘“βˆˆπΉ β€² βˆͺ𝐹 βˆ’
β€’ 𝐹′ = βˆ…
0.9 βˆ— 1 βˆ— 0.01 + 0.99 βˆ—
= 0.763
0.7 βˆ— 1 βˆ— 0.1 + 0.9 βˆ—
1 βˆ— 0.8 βˆ— 0.2 + 0.8 βˆ—
0.5 βˆ— 0.2 βˆ— 0.2 + 0.8
β€’ 𝐹 β€² = 𝑀1
0.8 βˆ— 0.9 βˆ— 1 βˆ— 0.01 + 0.99 βˆ— 0.1 βˆ— 1 βˆ— 0.7 βˆ— 0.1 + 0.9 βˆ—
βˆ— 1 βˆ— 0.5 βˆ— 0.2 βˆ— 0.2 + 0.8 = 0.712
1 βˆ— 1 βˆ— 0.8 βˆ— 0.2 + 0.8
β€’ 𝐹 β€² = 𝑀3 : 0,644, 𝐹 β€² = 𝑀1 , 𝑀3 : 0.602 β‡’ 𝑝 𝐹 + , 𝐹 βˆ’ = 0.763 βˆ’ 0.712 βˆ’ 0.644
+ 0.602 = 0.009
Quicksort calculation (2)
β€’ Let’s say we are interested in 𝑑1 . We’ll set the probability as (12)
requires, and
β€’ 𝐹′ = βˆ…
β€’
0.9 βˆ— 1 βˆ— 1 + 0 βˆ—
0.7 βˆ— 1 βˆ— 0.1 + 0.9 βˆ—
1 βˆ— 0.8 βˆ— 0.2 + 0.8 βˆ—
0.5 βˆ— 0.2