Docsity

Graphical Models: Inference - Slides | CMSC 726, Study notes of Computer Science

Toggle sidebar
bg1
1
cmsc726: Graphical
Models: Inference
material from: Michael Jordan, Nir Friedman and Daphne Koller
Inference
• We now have compact representations of probability
distributions: Bayesian Networks
• Network describes a unique probability distribution
P
• How do we answer queries about
P
?
• We use inference as a name for the process of
computing answers to such queries
Queries: Likelihood
• There are many types of queries we might ask.
• Most of these involve evidence
–Evidence
e
is an assignment of values to a set
E
variables in
the domain
– Without loss of generality
E= { X
k+1
, …, X
n
}
• Simplest query: compute probability of evidence
• This is often referred to as computing the likelihood
of the evidence
)( =
e
P∑∑
1
x1),,,(
k
xk
xxP
e
KK
Queries
• There are many types of queries we might ask.
• Most of these involve evidence
–Evidence
e
is an assignment of values to a set
E
variables in
the domain
– Without loss of generality
E= { X
k+1
, …, X
n
}
Queries: Conditional Probability
• Often we are interested in the conditional probability of a
variable given the evidence
•This is the a posteriori belief in X, given evidence
e
• A related task is computing the term
P(X, e)
– i.e., the likelihood of
e
and
X = x
for values of
X
– we can recover the a posteriori belief by
∑
′
′
=
=
==
x
xXP
x
X
P
xXP
),(
),(
)|(
e
e
e
)(
),(
)|(
eP
e
X
P
eXP
=
A posteriori belief
This query is useful in many cases:
•Prediction: what is the probability of an outcome given
the starting condition
– Target is a descendent o f the evidence
•Diagnosis: what is the probability of disease/fault given
symptoms
– Target is an ancestor of the evidence
• As we shall see, the direction between variables does not
restrict the directions of the queries
– Probabilistic inference can combine evidence form all parts of the
network
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Graphical Models: Inference - Slides | CMSC 726 and more Study notes Computer Science in PDF only on Docsity!

cmsc726: Graphical

Models: Inference

material from: Michael Jordan, Nir Friedman and Daphne Koller

Inference

  • We now have compact representations of probability distributions: Bayesian Networks
  • Network describes a unique probability distribution P
  • How do we answer queries about P?
  • We use inference as a name for the process of computing answers to such queries

Queries: Likelihood

  • There are many types of queries we might ask.
  • Most of these involve evidence
    • Evidence e is an assignment of values to a set E variables in the domain
    • Without loss of generality E = { X (^) k+1, …, X (^) n }
  • Simplest query: compute probability of evidence
  • This is often referred to as computing the likelihood of the evidence

P ( e )=∑ ∑ x 1

x k

K Px K xk e

Queries

  • There are many types of queries we might ask.
  • Most of these involve evidence
    • Evidence e is an assignment of values to a set E variables in the domain
    • Without loss of generality E = { X (^) k+1, …, X (^) n }

Queries: Conditional Probability

  • Often we are interested in the conditional probability of a variable given the evidence
  • This is the a posteriori belief in X, given evidence e
  • A related task is computing the term P(X, e )
    • i.e., the likelihood of e and X = x for values of X
    • we can recover the a posteriori belief by

∑ ′

x

PX x
PX x
P X x
e
e
e

Pe

PXe

P X e =

A posteriori belief

This query is useful in many cases:

  • Prediction : what is the probability of an outcome given the starting condition - Target is a descendent of the evidence
  • Diagnosis : what is the probability of disease/fault given symptoms - Target is an ancestor of the evidence
  • As we shall see, the direction between variables does not restrict the directions of the queries - Probabilistic inference can combine evidence form all parts of the network

Queries: Most Probable Assignment

  • In this query we want to find the most probable joint assignment for some variables of interest
  • Two flavors:
    • MPE – most probable explanation
    • MAP - maximum a posterior query (combination of conditional probability and MPE)
MPE ( X | e )=argmax xP ( x , e )

= (^) ∑ z

MAP ( Y | e ) argmax y P ( y , z | e )

Queries: MPA

We can use MAP for:

  • Classification
    • find most likely label, given the evidence
  • Explanation
    • What is the most likely scenario, given the evidence

Queries: MPA

Cautionary note:

  • The MPA depends on the set of variables
  • Example:
    • MPA of X
    • MPA of (X, Y)

x y P(x,y) 0 0 0. 0 1 0. 1 0 0. 1 1 0.

Complexity of Inference

Thm: Computing P(X = x) in a Bayesian network is NP-hard

Not surprising, since we can simulate Boolean gates.

Hardness

  • Hardness does not mean we cannot solve inference
    • It implies that we cannot find a general procedure that works efficiently for all networks
    • For particular families of networks, we can have provably efficient procedures

Approaches to inference

  • Exact inference
    • Inference in Simple Chains
    • Variable elimination
    • Clustering / join tree algorithms
  • Approximate inference
    • Stochastic simulation / sampling methods
    • Markov chain Monte Carlo methods
    • Variational Methods

Elimination in Chains

  • Now we can perform innermost summation
  • This summation, is exactly the first step in the forward iteration we describe before
A B C D E

d c b

d c b a

Pc bPd cPe dpb
Pe Pc bPd cPe d PaPb a

X

Elimination in Chains

  • Rearranging and then summing again, we get
A B C D E

d c

d c b

d c b

Pd cPe dpc
Pd cPe d Pc bpb
Pe Pc bPd cPe dpb

X X

  • Let’s move to more complex BNs….

Variable Elimination

General idea:

  • Write query in the form
  • Iteratively
    • Move all irrelevant terms outside of innermost sum
    • Perform innermost sum, getting a new term
    • Insert the new term into the product

x k x x i

PXn Pxi pai

3 2

( , e ) L ( | )

A More Complex Example

Visit to Asia Smoking

Tuberculosis Lung Cancer

Abnormality in Chest Bronchitis

X-Ray Dyspnea

  • “Asia” network:

V S

T L

A B

X D

P(v)P(s)P(t|v)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b )

  • We want to compute P(d)
  • Need to eliminate: v,s,x,t,l,a,b

Initial factors

V S

T L

A B

X D

P(v)P(s)P(t|v)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b )

  • We want to compute P(d)
  • Need to eliminate: v,s,x,t,l,a,b

Initial factors

Eliminate: v

Note: f (^) v (t) = P(t) In general, result of elimination is not necessarily a probability term

Compute: =∑ v

fv (t) P(v)P(t|v)
⇒fv(t)P(s)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b)

V S

T L

A B

X D

P(v)P(s)P(t|v)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b )
  • We want to compute P(d)
  • Need to eliminate: s,x,t,l,a,b
  • Initial factors
Eliminate: s
Summing on s results in a factor with two arguments fs (b,l)

In general, result of elimination may be a function of several variables

Compute: =∑ s

fs (b,l) P(s)P(b|s)P(l|s)
⇒fv(t)P(s)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b)
⇒fv (t)fs(b,l)P(a|t,l)P(x|a)P(d|a,b )

V S

T L

A B

X D

P(v)P(s)P(t|v)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b )
  • We want to compute P(d)
  • Need to eliminate: x,t,l,a,b
  • Initial factors
Eliminate: x
Note: f x(a) = 1 for all values of a !!

Compute: =∑ x

fx (a) P(x|a)
⇒fv(t)P(s)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b)
⇒fv (t)fs(b,l)P(a|t,l)P(x|a)P(d|a,b )
⇒fv(t)fs(b,l)fx(a)P(a|t,l)P(d|a,b )

V S

T L

A B

X D

P(v)P(s)P(t|v)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b )
  • We want to compute P(d)
  • Need to eliminate: t,l,a,b
  • Initial factors
Eliminate: t

Compute: =∑ t

ft (a,l) fv(t)P(a|t,l)
⇒fv(t)P(s)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b)
⇒fv (t)fs(b,l)P(a|t,l)P(x|a)P(d|a,b )
⇒fv(t)fs(b,l)fx(a)P(a|t,l)P(d|a,b )
⇒fs(b,l)fx(a)ft(a,l)P(d|a,b )

V S

T L

A B

X D

P(v)P(s)P(t|v)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b )
  • We want to compute P(d)
  • Need to eliminate: l,a,b
  • Initial factors
Eliminate: l

Compute: =∑ l

fl (a,b) fs(b,l)ft(a,l)
⇒fv(t)P(s)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b)
⇒fv (t)fs(b,l)P(a|t,l)P(x|a)P(d|a,b )
⇒fv(t)fs(b,l)fx(a)P(a|t,l)P(d|a,b )
⇒fs(b,l)fx(a)ft(a,l)P(d|a,b )
⇒fl (a,b)fx(a)P(d|a,b )

V S

T L

A B

X D

P(v)P(s)P(t|v)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b )
  • We want to compute P(d)
  • Need to eliminate: b
  • Initial factors
Eliminate: a,b

Compute: =∑ = ∑ b

b a a

fa (b,d) fl(a,b)fx(a)p(d|a,b) f(d) f(b,d)
⇒fv(t)P(s)P(l|s)P(b|s)P(a|t,l)P(x|a)P(d|a,b)
⇒fv (t)fs(b,l)P(a|t,l)P(x|a)P(d|a,b )
⇒fv(t)fs(b,l)fx(a)P(a|t,l)P(d|a,b )
⇒fl (a,b)fx(a)P(d|a,b )
⇒fs(b,l)fx(a)ft(a,l)P(d|a,b )
⇒fa (b,d)⇒fb(d )

Dealing with Evidence

  • Given evidence V = t, S = f, D = t
  • Compute P(L, V = t, S = f, D = t )
  • Initial factors, after setting evidence:
  • Eliminating x, we get
  • Eliminating t, we get
  • Eliminating a, we get
fP(v)fP(s)fP(t|v)(t )fP(l|s)(l)fP(b|s)(b)P(a|t,l)P(x|a)fP(d|a,b)(a,b )

V S

T L

A B

X D

fP(v)fP(s)fP(t|v)(t )fP(l|s)(l)fP(b|s)(b)P(a|t,l)fx(a)fP(d|a,b)(a,b )

fP(v)fP(s)fP(l|s)( l)fP(b|s)(b)ft(a,l)fx(a)fP(d|a,b)(a,b)

fP(v)fP(s)fP(l|s)( l)fP(b|s)(b)fa(b,l)

Dealing with Evidence

  • Given evidence V = t, S = f, D = t
  • Compute P(L, V = t, S = f, D = t )
  • Initial factors, after setting evidence:
  • Eliminating x, we get
  • Eliminating t, we get
  • Eliminating a, we get
  • Eliminating b, we get
fP(v)fP(s)fP(t|v)(t )fP(l|s)(l)fP(b|s)(b)P(a|t,l)P(x|a)fP(d|a,b)(a,b )

V S

T L

A B

X D

fP(v)fP(s)fP(t|v)(t )fP(l|s)(l)fP(b|s)(b)P(a|t,l)fx(a)fP(d|a,b)(a,b )
fP(v)fP(s)fP(l|s)(l )fP(b|s)(b)ft(a,l)fx(a)fP(d|a,b)(a,b)
fP(v)fP(s)fP(l|s)(l )fP(b|s)(b)fa(b,l)
fP(v)fP(s)fP(l|s)(l)fb(l)

= ∑ x

fx ( y 1 , K,yk) f'x(x,y 1 ,K,yk)

∏

m

i l

f (^) x xy yk fixy yi 1 1 ,

' (, 1 ,K, ) ( , 1 , 1 ,K, )

Complexity of variable elimination

  • Suppose in one elimination step we compute

This requires

  • multiplications
    • For each value for x, y 1 , …, y (^) k, we do m multiplications
  • additions
    • For each value of y 1 , …, y (^) k , we do |Val(X)| additions

Complexity is exponential in number of variables in the intermediate factor

i

m Val(X) Val(Yi)

i

Val(X ) Val(Yi)

Understanding Variable Elimination

  • We want to select “good” elimination orderings that reduce complexity
  • We start by attempting to understand variable elimination via the graph we are working with
  • This will reduce the problem of finding good ordering to graph-theoretic operation that is well-understood

Undirected graph representation

  • At each stage of the procedure, we have an algebraic term that we need to evaluate
  • In general this term is of the form:
where Z i are sets of variables
  • We now plot a graph where there is undirected edge
X--Y if X,Y are arguments of some factor
  • that is, if X,Y are in some Z i
  • Note: this is the Markov network that describes the probability on the variables we did not eliminate yet

= ∑ ∑∏ 1

y y i

k i n

PxKx K f Z i

Chordal Graphs

  • elimination ordering ⇒ undirected chordal graph

Graph:

  • Maximal cliques are factors in elimination
  • Factors in elimination are cliques in the graph
  • Complexity is exponential in size of the largest clique in graph

T L

A B

X

V S

D

V S

T L

A B

X D

Induced Width

  • The size of the largest clique in the induced graph is thus an indicator for the complexity of variable elimination
  • This quantity is called the induced width of a graph according to the specified ordering
  • Finding a good ordering for a graph is equivalent to finding the minimal induced width of the graph

General Networks

  • From graph theory: Thm:
  • Finding an ordering that minimizes the induced width is NP-Hard However,
  • There are reasonable heuristic for finding “relatively” good ordering
  • There are provable approximations to the best induced width
  • If the graph has a small induced width, there are algorithms that find it in polynomial time

Elimination on Trees

  • Formally, for any tree, there is an elimination ordering with induced width = 1

Thm

  • Inference on trees is linear in number of variables

PolyTrees

  • A polytree is a network where there is at most one path from one variable to another

Thm:

  • Inference in a polytree is linear in the representation size of the network - This assumes tabular CPT representation

A

B C

D E

F G

H

Approaches to inference

  • Exact inference
    • Inference in Simple Chains
    • Variable elimination
    • Clustering / join tree algorithms
  • Approximate inference
    • Stochastic simulation / sampling methods
    • Markov chain Monte Carlo methods
    • Mean field theory

Stochastic simulation

  • Suppose you are given values for some subset of the variables, G, and want to infer values for unknown variables, U
  • Randomly generate a very large number of instantiations from the BN - Generate instantiations for all variables – start at root variables and work your way “forward”
  • Only keep those instantiations that are consistent with the values for G
  • Use the frequency of values for U to get estimated probabilities
  • Accuracy of the results depends on the size of the sample (asymptotically approaches exact results)