Bayesian networks (2) Lirong Xia Last class Bayesian networks - - PowerPoint PPT Presentation

bayesian networks 2
SMART_READER_LITE
LIVE PREVIEW

Bayesian networks (2) Lirong Xia Last class Bayesian networks - - PowerPoint PPT Presentation

Bayesian networks (2) Lirong Xia Last class Bayesian networks compact, graphical representation of a joint probability distribution conditional independence 2 Bayesian network Definition of Bayesian network (Bayes net or


slide-1
SLIDE 1

Lirong Xia

Bayesian networks (2)

slide-2
SLIDE 2
  • Bayesian networks

– compact, graphical representation of a joint probability distribution – conditional independence

2

Last class

slide-3
SLIDE 3

Bayesian network

3

  • Definition of Bayesian network (Bayes’

net or BN)

  • A set of nodes, one per variable X
  • A directed, acyclic graph
  • A conditional distribution for each node

– A collection of distributions over X, one for each combination of parents’ values p(X|a1,…, an) – CPT: conditional probability table – Description of a noisy “causal” process

p X A

1…An

( )

A Bayesian network = Topology (graph) + Local Conditional Probabilities

slide-4
SLIDE 4

Probabilities in BNs

4

  • Bayesian networks implicitly encode joint distributions

– As a product of local conditional distributions – Example:

  • This lets us reconstruct any entry of the full joint
  • Not every BN can represent every joint distribution

– The topology enforces certain conditional independencies

p x1,x2,xn

( ) =

p xi parents X i

( )

( )

i=1 n

p +Cavity, +Catch, -Toothache

( )

slide-5
SLIDE 5

Reachability (D-Separation)

5

  • Question: are X and Y conditionally

independent given evidence vars {Z}?

– Yes, if X and Y “separated” by Z – Look for active paths from X to Y – No active paths = independence!

  • A path is active if each triple is

active:

– Causal chain where B is unobserved (either direction) – Common cause where B is unobserved – Common effect where B

  • r one of its descendents is observed
  • All it takes to block a path is a

single inactive segment

A B C → → A B C ← → A B C → ←

slide-6
SLIDE 6
  • Given random variables Z1,…Zp,

we are asked whether X⊥Y|Z1,…Zp

  • Step 1: shade Z1,…Zp
  • Step 2: for each undirected path

from X to Y

– if all triples are active, then X and Y are NOT conditionally independent

  • If all paths have been checked

and none of them is active, then X⊥Y|Z1,…Zp

6

Checking conditional independence from BN graph

slide-7
SLIDE 7

Example

7

' R B R B T R B T ⊥ ⊥ ⊥

Yes!

slide-8
SLIDE 8

Example

8

' ' , L T T L B L B T L B T L B T R ⊥ ⊥ ⊥ ⊥ ⊥

Yes! Yes! Yes!

slide-9
SLIDE 9

Example

9

, T D T D R T D R S ⊥ ⊥ ⊥

Yes!

  • Variables:

– R: Raining – T: Traffic – D: Roof drips – S: I am sad

  • Questions:
slide-10
SLIDE 10

10

Today: Inference---variable elimination (dynamic programming)

slide-11
SLIDE 11

Inference

11

  • Inference: calculating

some useful quantity from a joint probability distribution

  • Examples:

– Posterior probability: – Most likely explanation:

p Q E1 = e1,Ek = ek

( )

argmaxq p Q = q E1 = e1,

( )

slide-12
SLIDE 12

Inference

12

  • Given unlimited time, inference in BNs is easy
  • Recipe:

– State the marginal probabilities you need – Figure out ALL the atomic probabilities you need – Calculate and combine them

  • Example:

( )

( ) ( )

, , , , p b j m p b j m p j m + + + + + + = + +

slide-13
SLIDE 13

Example: Enumeration

13

  • In this simple method, we only need the BN to

synthesize the joint entries

( ) ( ) ( ) (

) ( ) ( )

( ) ( ) (

) ( ) ( )

( ) ( ) (

) ( ) ( )

( ) ( ) (

) ( ) ( )

, , , , , , p b j m p b p e p a b e p j a p m a p b p e p a b e p j a p m a p b p e p a b e p j a p m a p b p e p a b e p j a p m a + + + = + + + + + + + + + + + + − + + + − + − + + − + + − + + + + + + − − + − + − + −

slide-14
SLIDE 14

Inference by Enumeration?

14

slide-15
SLIDE 15

More elaborate rain and sprinklers example

Rained Sprinklers were on Grass wet Dog wet Neighbor walked dog

p(+R) = .2 p(+N|+R) = .3 p(+N|-R) = .4 p(+S) = .6 p(+G|+R,+S) = .9 p(+G|+R,-S) = .7 p(+G|-R,+S) = .8 p(+G|-R,-S) = .2 p(+D|+N,+G) = .9 p(+D|+N,-G) = .4 p(+D|-N,+G) = .5 p(+D|-N,-G) = .3

slide-16
SLIDE 16

Inference

  • Want to know: p(+R|+D) = p(+R,+D)/P(+D)
  • Let’s compute p(+R,+D)

Rained Sprinklers were on Grass wet Dog wet Neighbor walked dog

p(+R) = .2 p(+N|+R) = .3 p(+N|-R) = .4 p(+S) = .6 p(+G|+R,+S) = .9 p(+G|+R,-S) = .7 p(+G|-R,+S) = .8 p(+G|-R,-S) = .2 p(+D|+N,+G) = .9 p(+D|+N,-G) = .4 p(+D|-N,+G) = .5 p(+D|-N,-G) = .3

slide-17
SLIDE 17

Inference

  • p(+R,+D)= ΣsΣgΣn p(+R)p(s)p(n|+R)p(g|+R,s)p(+D|n,g) =

p(+R)Σsp(s)Σgp(g|+R,s)Σn p(n|+R)p(+D|n,g) Rained Sprinklers were on Grass wet Dog wet Neighbor walked dog

p(+R) = .2 p(+N|+R) = .3 p(+N|-R) = .4 p(+S) = .6 p(+G|+R,+S) = .9 p(+G|+R,-S) = .7 p(+G|-R,+S) = .8 p(+G|-R,-S) = .2 p(+D|+N,+G) = .9 p(+D|+N,-G) = .4 p(+D|-N,+G) = .5 p(+D|-N,-G) = .3

slide-18
SLIDE 18

p(+R)Σsp(s) Σgp(g|+R,s) Σn p(n|+R)p(+D|n,g)

  • Order: s>g>n
  • is what we want to compute
  • nly involves s
  • nly involves s, g

18

The formula

f1(s) f2(s,g)

p(+R,+D)=

slide-19
SLIDE 19

Variable elimination

  • From the factor Σn p(n|+R)p(+D|n,g) we sum out n to obtain a factor only depending on g
  • f2(s, g) happens to be insensitive to s, lucky!
  • f2(s,+G) = [Σn p(n|+R)p(+D|n,+G)] = p(+N|+R)P(+D|+N,+G) + p(-N|+R)p(+D|-N,+G) = .3*.9+.7*.5 =

.62

  • f2(s,-G) = [Σn p(n|+R)p(+D|n,-G)] = p(+N|+R)p(+D|+N,-G) + p(-N|+R)p(+D|-N,-G) = .3*.4+.7*.3 = .33

Rained Sprinklers were on Grass wet Dog wet Neighbor walked dog

p(+R) = .2 p(+N|+R) = .3 p(+N|-R) = .4 p(+S) = .6 p(+G|+R,+S) = .9 p(+G|+R,-S) = .7 p(+G|-R,+S) = .8 p(+G|-R,-S) = .2 p(+D|+N,+G) = .9 p(+D|+N,-G) = .4 p(+D|-N,+G) = .5 p(+D|-N,-G) = .3

slide-20
SLIDE 20
  • f1(s) = p(+G|+R,s) f2(s,+G) + p(-G|+R,s)

f2(s,-G)

  • f1(+S) = p(+G|+R,+S) f2(+S,+G) + p(-

G|+R, +S) f2(+S,-G) = 0.9*0.62+0.1*0.33=0.591

  • f1(-S) = p(+G|+R,-S) f2(-S,+G) + p(-G|+R,
  • S) f2(-S,-G) = 0.7*0.62+0.3*0.33=0.533

20

Calculating f1(s)

slide-21
SLIDE 21
  • p(+R,+D)= p(+R)p(+S) f1(+S) + p(+R)p(-

S) f1(-S) =0.2*(0.6*0.591+0.4*0.533)=0.11356

21

Calculating p(+R,+D)

slide-22
SLIDE 22

Elimination order matters

  • p(+R,+D)= ΣnΣsΣg p(+r)p(s)p(n|+R)p(g|+r,s)p(+D|n,g) =

p(+R)Σnp(n|+R)Σsp(s)Σg p(g|+R,s)p(+D|n,g)

  • Last factor will depend on two variables in this case!

Rained Sprinklers were on Grass wet Dog wet Neighbor walked dog

p(+R) = .2 p(+N|+R) = .3 p(+N|-R) = .4 p(+S) = .6 p(+G|+R,+S) = .9 p(+G|+R,-S) = .7 p(+G|-R,+S) = .8 p(+G|-R,-S) = .2 p(+D|+N,+G) = .9 p(+D|+N,-G) = .4 p(+D|-N,+G) = .5 p(+D|-N,-G) = .3

slide-23
SLIDE 23
  • Compute a marginal probability p(x1,…,xp) in a

Bayesian network

– Let Y1,…,Yk denote the remaining variables – Step 1: fix an order over the Y’s (wlog Y1>…>Yk) – Step 2: rewrite the summation as

Σy1 Σy2 …Σyk-1 Σykanything

– Step 3: variable elimination from right to left

23

General method for variable elimination

sth only involving X’s sth only involving Y1 and X’s

sth only involving Y1, Y2 and X’s

sth only involving Y1, Y2,…,Yk-1 and X’s