Cooperating Intelligent Systems
Bayesian networks
Chapter 14, AIMA
Inference
•
Inference in the statistical setting means
computing probabilities for different
outcomes to be true given the information
•
We need an efficient method for doing
this, which is more powerful than the
naïve Bayes model.
)

(
n
Informatio
Outcome
P
Bayesian networks
A
Bayesian network
is a directed graph in which
each node is annotated with quantitative
probability information:
1.
A set of random variables,
{
X
1
,X
2
,X
3
,...}
, makes up
the nodes of the network.
2.
A set of directed links connect pairs of nodes,
parent
child
3.
Each node
X
i
has a conditional probability
distribution
P
(
X
i

Parents
(
X
i
))
.
4.
The graph is a directed acyclic graph (DAG).
The dentist network
Cavity
Catch
Toothache
Weather
The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
Burglar alarm responds to
both earthquakes and burglars.
Two neighbors: John and Mary,
who have promised to call you
when the alarm goes off.
John always calls when there’s
an alarm, and sometimes when
there’s not an alarm.
Mary sometimes misses the
alarms (she likes loud music).
The cancer network
From Breese and Coller 1997
Age
Gender
Smoking
Toxics
Cancer
Serum
Calcium
Lung
Tumour
Genetic
Damage
The cancer network
From Breese and Coller 1997
Age
Gender
Smoking
Toxics
Cancer
Serum
Calcium
Lung
Tumour
Genetic
Damage
P
(
A,G
) =
P
(
A
)
P
(
G
)
P
(
C

S,T
,
A,G
) =
P
(
CS,T
)
P
(SC,C,LT,GD
) =
P
(
SCC
)
P
(
LTC,GD
)
P
(C)
P
(GD)
P
(
A,G,T,S,C,SC,LT,GD
)
=
P
(
A
)
P
(
G
)
P
(
TA
)
P
(
SA,G
)
P
(
CT,S
)
P
(
GD
)
P
(
SCC
)
P
(
LTC,GD
)
The product (chain) rule
n
i
i
i
n
n
n
X
parents
x
P
x
x
x
P
x
X
x
X
x
X
P
1
2
1
2
2
1
1
))
(

(
)
,
,
,
(
)
(
(This is for Bayesian networks, the general case comes
later in this lecture)
Bayes network node is a function
A
B
¬
a
b
a
∧
b
a
∧
¬
b
¬
a
∧
b
¬
a
∧
¬
b
Min
0.1
0.3
0.7
0.0
Max
1.5
1.1
1.9
0.9
C
P(C
¬
a,b) = U[0.7,1.9]
0.7
1.9
Bayes network node is a function
A
B
C
A BN node is a conditional
distribution function
•
Inputs = Parent values
•
Output = distribution over values
Any type of function from values
to distributions.
Example: The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
P(B=b)
0.001
P(E=e)
0.002
A
P(J=j)
a
0.90
¬
a
0.05
A
P(M=m)
a
0.70
¬
a
0.01
B
E
P(A=a)
b
e
0.95
b
¬
e
0.94
¬
b
e
0.29
¬
b
¬
e
0.001
Note: Each number in
the tables represents a
boolean distribution.
Hence there is a
distribution output for
every input.
Example: The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
P(B=b)
0.001
P(E=e)
0.002
A
P(J=j)
a
0.90
¬
a
0.05
A
P(M=m)
a
0.70
¬
a
0.01
B
E
P(A=a)
b
e
0.95
b
¬
e
0.94
¬
b
e
0.29
¬
b
¬
e
0.001
00063
.
0
90
.
0
70
.
0
001
.
0
998
.
0
999
.
0
)

(
)

(
)
,

(
)
(
)
(
)
(
a
j
P
a
m
P
e
b
a
P
e
P
b
P
e
b
a
m
j
P
Probability distribution for
”no earthquake, no burglary,
but alarm, and both Mary and
John make the call”
Meaning of Bayesian network
n
i
n
i
i
n
n
n
n
n
n
x
x
x
P
x
x
x
P
x
x
x
x
P
x
x
x
x
P
x
x
x
P
x
x
x
x
P
x
x
x
P
1
1
4
3
4
3
2
3
2
1
3
2
3
2
1
2
1
)
,
,

(
)
,
,
,
(
)
,
,
,

(
)
,
,
,

(
)
,
,
,
(
)
,
,
,

(
)
,
,
,
(
The general chain rule (always true):
n
i
i
i
n
X
parents
x
P
x
x
x
P
1
2
1
))
(

(
)
,
,
,
(
The Bayesian network chain rule:
The BN is a correct representation of the domain
iff
each node is
conditionally independent of its predecessors, given its parents.
The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
The fully correct alarm
network might look
something like the figure.
The Bayesian network
(red)
assumes that some of the
variables are independent (or
that the dependecies can be
neglected since they are very
weak).
The correctness of the
Bayesian network of course
depends on the validity of
these assumptions.
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
It is this sparse connection structure that makes the BN approach
feasible (~linear growth in complexity rather than exponential)
How construct a BN?
•
Add nodes in causal order (”causal”
determined from expertize).
•
Determine conditional independence using
either (or all) of the following semantics:
–
Blocking/d

separation rule
–
Non

descendant rule
–
Markov blanket rule
–
Experience/your beliefs
Path blocking & d

separation
Intuitively, knowledge about Serum Calcium influences our belief
about Cancer, if we don’t know the value of Cancer, which in turn
influences our belief about Lung Tumour, etc.
However, if we are given the value of Cancer (i.e. C=
true
or
false
),
then knowledge of Serum Calcium will not tell us anything about
Lung Tumour that we don’t already know.
We say that Cancer
d

separates
(direction

dependent separation)
Serum Calcium and Lung Tumour.
Cancer
Serum
Calcium
Lung
Tumour
Genetic
Damage
Path blocking & d

separation
Two nodes
X
i
and
X
j
are conditionally independent given a set
W
= {
X
1
,X
2
,X
3
,...}
of nodes if for every undirected path in
the BN between
X
i
and
X
j
there is some node
X
k
on the
path having one of the following three properties:
1.
X
k
∈
W
, and both arcs on the path
lead out of
X
k
.
2.
X
k
∈
W
, and one arc on the path
leads into
X
k
and one arc leads
out.
3.
Neither
X
k
nor any descendant of
X
k
is in
W
, and both arcs on the
path lead into
X
k
.
X
k
blocks
the path between
X
i
and
X
j
X
i
X
j
X
k1
X
k2
X
k3
W
)

(
)

(
)

,
(
W
W
W
j
i
j
i
X
P
X
P
X
X
P
X
k1
X
k2
X
k3
X
i
and
X
j
are d

separated
if all paths betweeen them are blocked
Non

descendants
A node is conditionally
independent of its
non

descendants (
Z
ij
),
given its parents.
)
,
,

,
,
(
)
,
,

(
)
,
,

,
,
,
(
1
1
1
1
1
m
nj
j
m
m
nj
j
U
U
Z
Z
P
U
U
X
P
U
U
Z
Z
X
P
Markov blanket
A node is conditionally
independent of all
other nodes in the
network, given its
parents, children, and
children’s parents
These constitute the
nodes
Markov blanket
.
)
,
,
,
,
,
,
,
,

,
,
(
)
,
,
,
,
,
,
,
,

(
)
,
,
,
,
,
,
,
,

,
,
,
(
1
1
1
1
1
1
1
1
1
1
1
n
nj
j
m
k
n
nj
j
m
n
nj
j
m
k
Y
Y
Z
Z
U
U
X
X
P
Y
Y
Z
Z
U
U
X
P
Y
Y
Z
Z
U
U
X
X
X
P
X
1
X
2
X
3
X
4
X
5
X
6
X
k
Efficient representation of PDs
•
Boolean
Boolean
•
Boolean
Discrete
•
Boolean
Continuous
•
Discrete
Boolean
•
Discrete
Discrete
•
Discrete
Continuous
•
Continuous
Boolean
•
Continuous
Discrete
•
Continuous
Continuous
C
A
B
P(Ca,b) ?
Efficient representation of PDs
Boolean
Boolean:
Noisy

OR, Noisy

AND
Boolean/Discrete
Discrete:
Noisy

MAX
Bool./Discr./Cont.
Continuous:
Parametric distribution (e.g. Gaussian)
Continuous
Boolean:
Logit/Probit
Noisy

OR example
Boolean
→
Boolean
P(EC
1
,C
2
,C
3
)
C
1
0
1
0
0
1
1
0
1
C
2
0
0
1
0
1
0
1
1
C
3
0
0
0
1
0
1
1
1
P(E=0)
1
0.1
0.1
0.1
0.01
0.01
0.01
0.001
P(E=1)
0
0.9
0.9
0.9
0.99
0.99
0.99
0.999
Example from L.E. Sucar
The effect (E) is off (false) when none of the causes are true. The
probability for the effect increases with the number of true causes.
)
(#
10
)
0
(
True
E
P
(for this example)
Noisy

OR general case
Boolean
→
Boolean
false
true
C
q
C
C
C
E
P
i
n
i
C
i
n
i
if
0
if
1
)
,
,
,

0
(
1
2
1
Example on previous slide used
q
i
= 0.1 for all
i
.
q
1
P
(
E

C
1
,...)
C
1
C
2
C
n
q
2
q
n
PROD
Image adapted from Laskey & Mahoney 1999
Noisy

MAX
Boolean
→
Discrete
e
1
Observed effect
C
1
C
2
C
n
e
2
e
n
MAX
Effect takes on the max value from
different causes
Restrictions:
–
Each cause must have an off state,
which does not contribute to effect
–
Effect is off when all causes are off
–
Effect must have consecutive
escalating values: e.g., absent, mild,
moderate, severe.
Image adapted from Laskey & Mahoney 1999
n
i
C
k
i
n
k
i
q
C
C
C
e
E
P
1
,
2
1
)
,
,
,

(
Parametric probability densities
Boolean/Discr./Continuous
→
Continuous
Use parametric probability densities, e.g.,
the normal distribution
)
,
(
2
)
(
exp
2
1
)
(
2
2
N
x
X
P
Gaussian networks (
a
= input to the node)
2
2
2
)
(
exp
2
1
)
(
a
x
X
P
Probit & Logit
Discrete
→
Boolean
If the input is continuous but output is
boolean, use probit or logit
x
dx
x
x
a
A
P
x
x
a
A
P
)
/
)
(
exp(
2
1
)

(
:
Probit
/
)
(
2
exp
1
1
)

(
:
Logit
2
2
8
6
4
2
0
2
4
6
8
0
0.2
0.4
0.6
0.8
1
The logistic sigmoid
P(Ax)
x
The cancer network
Age: {1

10, 11

20,...}
Gender: {M, F}
Toxics: {Low, Medium, High}
Smoking: {No, Light, Heavy}
Cancer: {No, Benign, Malignant}
Serum Calcium: Level
Lung Tumour: {Yes, No}
Age
Gender
Smoking
Toxics
Cancer
Serum
Calcium
Lung
Tumour
Discrete
Discrete/boolean
Discrete
Discrete
Discrete
Continuous
Discrete/boolean
Inference in BN
Inference means computing
P
(
X

e
)
, where
X
is
a query (variable) and
e
is a set of evidence
variables (for which we know the values).
Examples:
P
(Burglary  john_calls, mary_calls)
P
(Cancer  age, gender, smoking, serum_calcium)
P
(Cavity  toothache, catch)
Exact inference in BN
”Doable” for boolean variables: Look up
entries in conditional probability tables
(CPTs).
y
y
e
P
e
P
e
P
e
P
e
P
)
,
,
(
)
,
(
)
(
)
,
(
)

(
X
X
X
X
Example: The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
P(B=b)
0.001
P(E=e)
0.002
A
P(J=j)
a
0.90
¬
a
0.05
A
P(M=m)
a
0.70
¬
a
0.01
B
E
P(A=a)
b
e
0.95
b
¬
e
0.94
¬
b
e
0.29
¬
b
¬
e
0.001
}
,
{
}
,
{
)
,
,
,
,
(
)
,

(
e
e
E
a
a
A
m
j
A
E
B
m
j
B
P
P
Evidence variables = {J,M}
Query variable = B
What is the probability for a burglary if both John and Mary call?
Example: The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
P(B=b)
0.001
P(E=e)
0.002
A
P(J=j)
a
0.90
¬
a
0.05
A
P(M=m)
a
0.70
¬
a
0.01
B
E
P(A=a)
b
e
0.95
b
¬
e
0.94
¬
b
e
0.29
¬
b
¬
e
0.001
)
(
)
(
)
,

(
)

(
)

(
)
,
(
)
,

(
)

(
)

(
)
,
,
(
)

(
)

(
)
,
,
(
)
,
,

,
(
)
,
,
,
,
(
E
P
b
P
E
b
a
P
A
m
P
A
j
P
E
b
E
b
a
P
A
m
P
A
j
P
A
E
b
A
m
P
A
j
P
A
E
b
A
E
b
m
j
m
j
A
E
b
B
P
P
P
P
P
=
0.001 = 10

3
What is the probability for a burglary if both John and Mary call?
)
(
)
,

(
)

(
)

(
10
3
E
P
E
b
A
P
A
m
P
A
j
P
}
,
{
}
,
{
)
,
,
,
,
(
)
,

(
e
e
E
a
a
A
m
j
A
E
B
m
j
B
P
P
Example: The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
P(B=b)
0.001
P(E=e)
0.002
A
P(J=j)
a
0.90
¬
a
0.05
A
P(M=m)
a
0.70
¬
a
0.01
B
E
P(A=a)
b
e
0.95
b
¬
e
0.94
¬
b
e
0.29
¬
b
¬
e
0.001
3
3
3
}
,
{
}
,
{
3
10
491
.
1
)
,
,
(
10
5923
.
0
)]
(
)
,

(
)

(
)

(
)
(
)
,

(
)

(
)

(
)
(
)
,

(
)

(
)

(
)
(
)
,

(
)

(
)

(
[
10
)
(
)
,

(
)

(
)

(
10
)
,
,
(
m
j
b
e
P
e
b
a
P
a
m
P
a
j
P
e
P
e
b
a
P
a
m
P
a
j
P
e
P
e
b
a
P
a
m
P
a
j
P
e
P
e
b
a
P
a
m
P
a
j
P
E
P
E
b
A
P
A
m
P
A
j
P
m
j
b
e
e
E
a
a
A
P
P
What is the probability for a burglary if both John and Mary call?
}
,
{
}
,
{
)
,
,
,
,
(
)
,

(
e
e
E
a
a
A
m
j
A
E
B
m
j
B
P
P
Example: The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
P(B=b)
0.001
P(E=e)
0.002
A
P(J=j)
a
0.90
¬
a
0.05
A
P(M=m)
a
0.70
¬
a
0.01
B
E
P(A=a)
b
e
0.95
b
¬
e
0.94
¬
b
e
0.29
¬
b
¬
e
0.001
716
.
0
)
,
,
(
)
,

(
284
.
0
)
,
,
(
)
,

(
]
10
083
.
2
[
)
,
,
(
)
,
,
(
)
,
(
10
491
.
1
)
,
,
(
10
5923
.
0
)
,
,
(
1
3
1
1
3
3
m
j
b
m
j
b
m
j
b
m
j
b
m
j
b
m
j
b
m
j
m
j
b
m
j
b
P
P
P
P
P
P
P
P
P
What is the probability for a burglary if both John and Mary call?
}
,
{
}
,
{
)
,
,
,
,
(
)
,

(
e
e
E
a
a
A
m
j
A
E
B
m
j
B
P
P
Example: The alarm network
Alarm
Burglary
Earthquake
JohnCalls
MaryCalls
P(B=b)
0.001
P(E=e)
0.002
A
P(J=j)
a
0.90
¬
a
0.05
A
P(M=m)
a
0.70
¬
a
0.01
B
E
P(A=a)
b
e
0.95
b
¬
e
0.94
¬
b
e
0.29
¬
b
¬
e
0.001
716
.
0
)
,
,
(
)
,

(
284
.
0
)
,
,
(
)
,

(
]
10
083
.
2
[
)
,
,
(
)
,
,
(
)
,
(
10
491
.
1
)
,
,
(
10
5923
.
0
)
,
,
(
1
3
1
1
3
3
m
j
b
m
j
b
m
j
b
m
j
b
m
j
b
m
j
b
m
j
m
j
b
m
j
b
P
P
P
P
P
P
P
P
P
What is the probability for a burglary if both John and Mary call?
Answer: 28%
}
,
{
}
,
{
)
,
,
,
,
(
)
,

(
e
e
E
a
a
A
m
j
A
E
B
m
j
B
P
P
Use depth

first search
A lot of unneccesary repeated computation...
Complexity of exact inference
•
By eliminating repeated calculation &
uninteresting paths we can speed up the
inference a lot.
•
Linear time complexity for singly
connected networks (polytrees).
•
Exponential for multiply connected
networks.
–
Clustering can improve this
Approximate inference in BN
•
Exact inference is intractable in large
multiply connected BNs
⇒
use approximate inference:
Monte Carlo methods (random sampling).
–
Direct sampling
–
Rejection sampling
–
Likelihood weighting
–
Markov chain Monte Carlo
Markov chain Monte Carlo
1.
Fix the evidence variables (E
1
, E
2
, ...) at their
given values.
2.
Initialize the network with values for all other
variables, including the query variable.
3.
Repeat the following many, many, many times:
a.
Pick a non

evidence variable at random (query X
i
or
hidden Y
j
)
b.
Select a new value for this variable, conditioned on the
current values in the variable’s Markov blanket.
Monitor the values of the query variables.
Enter the password to open this PDF file:
File name:

File size:

Title:

Author:

Subject:

Keywords:

Creation Date:

Modification Date:

Creator:

PDF Producer:

PDF Version:

Page Count:

Preparing document for printing…
0%
Comments 0
Log in to post a comment