57
Bayesian Networks Bucket Elimination Algorithm 主主主 主主主 主主主主主主主 主主主主主 主主主

Bayesian Networks Bucket Elimination Algorithm

  • Upload
    isleen

  • View
    97

  • Download
    0

Embed Size (px)

DESCRIPTION

Bayesian Networks Bucket Elimination Algorithm. 主講人:虞台文 大同大學資工所 智慧型多媒體研究室. Content. Basic Concept Belief Updating Most Probable Explanation (MPE) Maximum A Posteriori (MAP). Bayesian Networks Bucket Elimination Algorithm. Basic Concept 大同大學資工所 智慧型多媒體研究室. Satisfiability. - PowerPoint PPT Presentation

Citation preview

Page 1: Bayesian Networks Bucket Elimination Algorithm

Bayesian NetworksBucket Elimination Algorithm

主講人:虞台文

大同大學資工所智慧型多媒體研究室

Page 2: Bayesian Networks Bucket Elimination Algorithm

Content

Basic ConceptBelief UpdatingMost Probable Explanation (MPE)Maximum A Posteriori (MAP)

Page 3: Bayesian Networks Bucket Elimination Algorithm

Bayesian NetworksBucket Elimination Algorithm

Basic Concept

大同大學資工所智慧型多媒體研究室

Page 4: Bayesian Networks Bucket Elimination Algorithm

Satisfiability

Given a statement of clauses (in disjunction normal form), the satisfiability problem is to determine whether there exists a truth assignment to make the statement true.

1. ( ) ( ) ( ) ( )A B C C D A B D A D Examples:

A=True, B=True, C=False, D=False Satisfiable2. ( ) ( ) ( ) ( ) ( )A B C B C D B C A C D

Satisfiable?

Page 5: Bayesian Networks Bucket Elimination Algorithm

Resolution

( ) ( )q q can be true if and only if

can be true.

q q ?TURE

unsatisfiable

Page 6: Bayesian Networks Bucket Elimination Algorithm

Direct Resolution

A B C

B C D

B C

A C

D

Example:

Given a set of clauses

( ) ( ) ( ) ( ) ( )A B C B C D B C A C D

and an order d=ABCD

BucketA BucketB BucketC BucketD

B C D DA C

B C A B C

Set initial buckets as follows:

Page 7: Bayesian Networks Bucket Elimination Algorithm

Direct Resolution

( ) ( ) ( ) ( ) ( )A B C B C D B C A C D

BucketA BucketB BucketC BucketD

B C D DA C

B C A B C

B C

A B B

A B

Because no empty clause () is resulted, the statement is satisfiable.

How to get a truth assignment?

Page 8: Bayesian Networks Bucket Elimination Algorithm

Direct Resolution

( ) ( ) ( ) ( ) ( )A B C B C D B C A C D

BucketA BucketB BucketC BucketD

B C D DA C

B C A B C

B C

A B B

A B

True or FalseA TrueB

True if True

True/False if False

AC

A

FalseD

Page 9: Bayesian Networks Bucket Elimination Algorithm

Direct Resolution

Page 10: Bayesian Networks Bucket Elimination Algorithm

Queries on Bayesian Networks

Belief updating

Finding the most probable explanation (mpe)– Given evidence, finding a maximum probability assignment to t

he rest of variables. Maximizing a posteriori hypothesis (map)

– Given evidence, finding an assignment to a subset of hypothesis variables that maximize their probability.

Maximizing the expected utility of the problem (meu)– Given evidence and utility function, finding a subset of decision

variables that maximize the expected utility.

( | ) ?P X E

Page 11: Bayesian Networks Bucket Elimination Algorithm

Bucket Elimination

The algorithm will be used as a framework for various probabilistic inferences on Bayesian Networks.

Page 12: Bayesian Networks Bucket Elimination Algorithm

Preliminary – Elimination Functions

Given a function h defined over subset of variables S, where X S,

min

max

mean

X

X

X

X

h

h

h

h

Eliminate parameter X from h

Defined over U = S – {X}.

Page 13: Bayesian Networks Bucket Elimination Algorithm

Preliminary – Elimination Functions

Given a function h defined over subset of variables S, where X S,

min

max

mean

X

X

X

X

h

h

h

h

min min( ) ( , )X Xh h xu u

max max( ) ( , )X Xh h xu u

1

|( ) ( ,n )

|mea X XX

h xh u u

( ) ( , )X Xh h x u u

Page 14: Bayesian Networks Bucket Elimination Algorithm

Preliminary – Elimination Functions

Given function h1,…, hn defined over subset of variables S1,…, Sn, respectively,

j

j

j

j

h

h

Defined overjj

U S

Page 15: Bayesian Networks Bucket Elimination Algorithm

Preliminary – Elimination Functions

Given function h1,…, hn defined over subset of variables S1,…, Sn, respectively,

j

j

j

j

h

h

) (( )jj jj jh h Su u

) (( )jj jj jh h Su u

Page 16: Bayesian Networks Bucket Elimination Algorithm

Bayesian NetworksBucket Elimination Algorithm

Belief Updating

大同大學資工所智慧型多媒體研究室

Page 17: Bayesian Networks Bucket Elimination Algorithm

Goal

( | ) ?X xP E e

( , )

( )

X xP

P

E e

E eNormalization

Factor

Page 18: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

Example:

A

B

D

C

F

G

( | ) ?1a gP

( , , , , , ) ( | ) ( | , ) ( | , ) ( | ) ( | ) ( )P g f d c b a P g f P f b c P d a b P b a P c a P a

( , ) ?1a gP

Page 19: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

Example:

( | ) ?1a gP

, , , , 1

( , ) ( , , , )1 , ,b c d f g

P P a b c d f gga

( , ) ?1a gP

, , , , 1

( ) ( | ) ( | , ) ( | , ) ( | ) ( | )b c d f g

P a P g f P f b c P d a b P b a P c a

1

( ) ( | ) ( | ) ( | , ) ( | , ) ( | )c b f d g

P a P c a P b a P f b c P d a b P g f

( , , , , , ) ( | ) ( | , ) ( | , ) ( | ) ( | ) ( )P g f d c b a P g f P f b c P d a b P b a P c a P a

Page 20: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

( | ) ?1a gP

1( , )P a g

( , ) ?1a gP

1

( ) ( | ) ( | ) ( | , ) ( | , ) ( | )c b f d g

P a P c a P b a P f b c P d a b P g f

G(f)

( ) ( | ) ( | ) ( | , () ( | , ))c b f

Gd

P a P c a P b a P f b c P d a bf D(a, b)

( ) ( | ) ( | ) ( , ) ( )( | , )D Gc b f

P a P c a P b a P f ba cb f F(b, c)

( , ) ( , )( ) ( | ) ( | )c b

D FP a P c a P b a a b b c B(a, c)

( ) ( | ) ( , )c

BP a P c ca a C(a)

)( ) (C aP a

Page 21: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

1

( ) ( | )Gg

P g ff

( )( ,, |)Dd

P db aa b

( | ,( , ) ( ))F Gf

P f b cb c f

( , ) ( , )) ( ,( )|b

B D Fa c a b bP a cb

( ) ( , )( | ) Bc

C P c aa a c ( ) ), ((1) CP P a aga

BucketG

BucketD

BucketF

BucketB

BucketC

BucketA

1( , )P a g

1

( ) ( | ) ( | ) ( | , ) ( | , ) ( | )c b f d g

P a P c a P b a P f b c P d a b P g f

Page 22: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

( | )P g f

( | , )P d a b

( | , )P f b c

( | )P b a

( | )P c a

( )P a

BucketG

BucketD

BucketF

BucketB

BucketC

BucketA

1( , )P a g

1

( ) ( | ) ( | ) ( | , ) ( | , ) ( | )c b f d g

P a P c a P b a P f b c P d a b P g f

1g

d

f

b

c

( )G f

( , )D a b

( , )F b c

( , )B a c

( )C a

( , 1)P a g

( )G f

( , )D a b ( , )F b c

( , )B a c

( )C a

Page 23: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

1

( ) ( | )Gg

P g ff

f G(f )

+ 0.1

0.7

Page 24: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

f G(f )

+ 0.1

0.7

( )( ,, |)Dd

P db aa b a b D(a,

b)

0 0 1

0 1 1

1 0 1

1 1 1

Page 25: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

f G(f )

+ 0.1

0.7

a b D(a, b)

0 0 1

0 1 1

1 0 1

1 1 1

( | ,( , ) ( ))F Gf

P f b cb c f

0.70.1

0.70.10.70.10.70.1

b c F(b, c)

0 0 0.701

0 1 0.610

1 0 0.400

1 1 0.340

Page 26: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

f G(f )

+ 0.1

0.7

a b D(a, b)

0 0 1

0 1 1

1 0 1

1 1 1

b c F(b, c)

0 0 0.701

0 1 0.610

1 0 0.400

1 1 0.340

( , ) ( , )) ( ,( )|b

B D Fa c a b bP a cb a c B(a, c)

0 0 0.90.701+0.1 0.400=0.6709

0 1 0.90.610+0.1 0.340=0.5830

1 0 0.60.701+0.4 0.400=0.5806

1 1 0.60.610+0.4 0.340=0.5020

Page 27: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

f G(f )

+ 0.1

0.7

a b D(a, b)

0 0 1

0 1 1

1 0 1

1 1 1

b c F(b, c)

0 0 0.701

0 1 0.610

1 0 0.400

1 1 0.340

a c B(a, c)

0 0 0.6709

0 1 0.5830

1 0 0.5806

1 1 0.5020

( ) ( , )( | ) Bc

C P c aa a c

a C(a )

1 0.67 0.5806+0.33 0.5020=0.554662

0 0.75 0.6709+0.25 0.5830=0.648925

Page 28: Bayesian Networks Bucket Elimination Algorithm

Basic Concept of Variable Elimination

f G(f )

+ 0.1

0.7

a b D(a, b)

0 0 1

0 1 1

1 0 1

1 1 1

b c F(b, c)

0 0 0.701

0 1 0.610

1 0 0.400

1 1 0.340

a c B(a, c)

0 0 0.6709

0 1 0.5830

1 0 0.5806

1 1 0.5020

a C(a )

1 0.554662

0 0.648925

( ) ), ((1) CP P a aga

a P(a, g=1)

1 0.30.554662=0.1663986

0 0.70.648925=0.4542475

( , )( | )

(

11

1)

aPP

P ga

gg

( 1) 0.1663986 0.4542475

0.6206461

P g

a P(a | g=1)1 0.1663986/0.6206461=0.268110 0.4542475/0.6206461=0.73189

Page 29: Bayesian Networks Bucket Elimination Algorithm

Bucket Elimination Algorithm

Page 30: Bayesian Networks Bucket Elimination Algorithm

Complexity The BuckElim Algorithm can be applied to any ordering. The arity of the function recorded in a bucket

– the numbers of variables appearing in the processed bucked, excluding the bucket’s variable.

Time and Space complexity is exponentially grow with a function of arity r.

The arity is dependent on the ordering. How many possible orderings for BN’s variables?

Page 31: Bayesian Networks Bucket Elimination Algorithm

Determination of the Arity

( | )P g f

( | , )P d a b ( | , )P f b c( | )P b a

( | )P c a

( )P a

BucketG

BucketB

BucketC

BucketD

BucketF

BucketA

1g

b

c

d

f

( )G f

( , , , )B a c d f

( , )D a f

( )F a

( , 1)P a g

( )G f

( , , )C a d f

A

B

D

C

F

G

Consider the ordering AFDCBG.

G

B

C

D

F

A( )F a

( , , , )B a c d f ( , , )C a d f

( , )D a f

1

4

1

0

0

0

,3

,2

,1

Page 32: Bayesian Networks Bucket Elimination Algorithm

Determination of the Arity

Given the ordering, e.g., AFDCBG.

1

4

0

3

2

1

G

B

C

D

F

A

G

B

C

D

F

A

1

4

1

0

0

0

A

B

D

C

F

G

InitialGraph

Width of node

InducedGraph

Width of node

d

w(d): width of initial graph for ordering d.w*(d): width of induced graph for ordering d.

w(d): width of initial graph for ordering d.w*(d): width of induced graph for ordering d.

The width of a graph is the maximum width of its nodes.

The width of a graph is the maximum width of its nodes. w(d) = 4 w*(d) = 4

Page 33: Bayesian Networks Bucket Elimination Algorithm

Definition of Tree-Width

Goal: Finding an ordering with smallest induced width.

NP-Hard Greedy heuristic and Approximation methodsAre available.

Page 34: Bayesian Networks Bucket Elimination Algorithm

Summary

The complexity of BuckElim algorithm is dominated by the time and space needed to process a bucket.

It is time and space is exponential in number of bucket variables.

Induced width bounds the arity of bucket functions.

Page 35: Bayesian Networks Bucket Elimination Algorithm

Exercises

A

B

D

C

F

G

Use BuckElim to evaluate P(a|b=1) with the following two ordering:

1. d1=ACBFDG

2. d2=AFDCBG

Give the details and make some conclusion.

How to improve the algorithm?

Page 36: Bayesian Networks Bucket Elimination Algorithm

Bayesian NetworksBucket Elimination Algorithm

Most Probable Explanation (MPE)

大同大學資工所智慧型多媒體研究室

Page 37: Bayesian Networks Bucket Elimination Algorithm

MPE

Goal:

arg max ( | )* ?P x

X x E exevidence

1( , , )nx xx

Page 38: Bayesian Networks Bucket Elimination Algorithm

arg max ( , ) ?* P x

exx

MPE

Goal:

arg max ( | )* ?P x

X x E ex

Page 39: Bayesian Networks Bucket Elimination Algorithm

Notationsarg max (* , )P

xx ex

i

iF

xi

i

Page 40: Bayesian Networks Bucket Elimination Algorithm

arg max (* , )Px

x ex

MPE1

( ) ( , ) ( , | )i

n

i iP P xP

X e ex x

( ) max ( )* max ( )n

nP P P X Xx x

x x x

Let 1( , , )n nx xx

1max ( , )|

n

n

ii ixP

x

e

1 , 1m x ( , )|a

n nx i i

n

ixP

x

e

Page 41: Bayesian Networks Bucket Elimination Algorithm

arg max (* , )Px

x ex

MPE*( )P x

1 , 1m x ( , )|a

n nx i i

n

ixP

x

e

Some terms involve xn,some terms not.

Xn

n

n

Xn is conditioned by its parents.

Xn conditions its children.

( , | )n nxP e

|( , ), ,k n k nP x x x e

Page 42: Bayesian Networks Bucket Elimination Algorithm

nF

arg max (* , )Px

x ex

MPE*( )P x

1 , 1m x ( , )|a

n nx i i

n

ixP

x

e

1

max ( , ) max ( , ) ( , )| | |n i nn i nX F i i n

xiXn ix xP P P x

Xxe e e

Xn

n

n

Not conditioned by x n Conditioned by x nItself

x n appears in these CPT’s

Page 43: Bayesian Networks Bucket Elimination Algorithm

arg max (* , )Px

x ex

MPE*( )P x

1 , 1m x ( , )|a

n nx i i

n

ixP

x

e

1

max ( , ) max ( , ) ( , )| | |n i nn i nX F i i n

xiXn ix xP P P x

Xxe e e

( )nnh xU

1

max ( , ) (| )i n n

ni iF nX

P xhx

X U

xe

Eliminate variable xn at Bucketn.

Process the next bucket recursively.

Page 44: Bayesian Networks Bucket Elimination Algorithm

Example

A

B

D

C

F

G

, , , ,, ,max ( 1) ?, , ,

a b c d fa b c gP d f

( ) ( | ) ( | , ) ( | , ) (, | ) ( | ), 1 1, , , ( )P P f P f b c Pg g d a b P b a P c aa b c f ad P

Page 45: Bayesian Networks Bucket Elimination Algorithm

ExampleA

B

D

C

F

G

, , , ,, ,max ( 1) ?, , ,

a b c d fa b c gP d f

( | )P g f

( | , )P d a b

( | , )P f b c

( | )P b a

( | )P c a

( )P a

BucketG

BucketD

BucketF

BucketB

BucketC

BucketA

1max

g

maxd

maxf

maxb

maxc

( )Gh f

( , )Dh a b

( , )Fh b c

( , )Bh a c

( )C a

, , , ,max ( , , , , , )1

a b c d fa b c d f gP

( )Gh f

( , )Dh a b ( , )Fh b c

( , )B a c

( )Ch amaxa

Consider ordering ACBFDG

Page 46: Bayesian Networks Bucket Elimination Algorithm

Bucket Elimination Algorithm

Page 47: Bayesian Networks Bucket Elimination Algorithm

Exercise, , , ,

, ,max ( 1) ?, , ,a b c d f

a b c gP d f

Consider ordering ACBFDG

Page 48: Bayesian Networks Bucket Elimination Algorithm

Bayesian NetworksBucket Elimination Algorithm

Maximum A Posteriori (MAP)

大同大學資工所智慧型多媒體研究室

Page 49: Bayesian Networks Bucket Elimination Algorithm

MAP

arg max ( , ) ?* P a

eaa

arg max ( | )* ?P a

A a E ea

Given a belief network, a subset of hypothesized variables A=(A1, …, Ak), and evidence E=e, the goal is to determine

Page 50: Bayesian Networks Bucket Elimination Algorithm

ExampleA

B

D

C

F

G

Hypothesis (Decision) Variables

,arg max ( | )*, * 1( ?) ,

b cc P c gbb

g = 1

Page 51: Bayesian Networks Bucket Elimination Algorithm

MAP

Ordering

1 1, ,, ,kk nd XX X X

1 1, , ,, kk nX XA A

1, nk k XA

Some of them may be observed

Page 52: Bayesian Networks Bucket Elimination Algorithm

MAP1, n

kkd XA

* arg max ( | )k

k kPa

a ea

( , )arg max

( )k

kP

P

a

ea

e

arg max ( , )k

kPa

a e

Page 53: Bayesian Networks Bucket Elimination Algorithm

MAP1, n

kkd XA

* arg max ( , )k

k kPa

a ea

11( , ) ( , , )n

kk k

nkP P

x

x eaea

1 1( , | )n

k

n

i iiP x

x

e

1

*

1( ) max ( , | )

knk

n

i iikP P x

xaa e

Page 54: Bayesian Networks Bucket Elimination Algorithm

MAP1, n

kkd XA

* arg max ( , )k

k kPa

a ea

1

*

1( ) max ( , | )

knk

n

i iikP P x

xaa e

Bucket Elimination for belief updating

Bucket Elimination for belief updating

Bucket Elimination for MPE

Bucket Elimination for MPE

Page 55: Bayesian Networks Bucket Elimination Algorithm

Bucket Elimination Algorithm

Page 56: Bayesian Networks Bucket Elimination Algorithm

ExampleA

B

D

C

F

G g = 1

Consider ordering CBAFDG

,arg max ( | )*, * 1( ?) ,

b cc P c gbb

( | )P g f

( | , )P d a b

( | , )P f b c

( | )P b a( | )P c a ( )P a

BucketG

BucketD

BucketF

BucketA

BucketB

BucketC

1g

d

f

a

maxb

( )G f

( , )D a b

( , )F b c

( , )A b c

( )b c

,max ( |, )1

b cb c gP

( )G f

( , )D a b

( , )F b c ( , )A b c

maxc

( )b c

Page 57: Bayesian Networks Bucket Elimination Algorithm

ExerciseA

B

D

C

F

G g = 1

Consider ordering CBAFDG

,arg max ( | )*, * 1( ?) ,

b cc P c gbb

( | )P g f

( | , )P d a b

( | , )P f b c

( | )P b a( | )P c a ( )P a

BucketG

BucketD

BucketF

BucketA

BucketB

BucketC

1g

d

f

a

maxb

( )G f

( , )D a b

( , )F b c

( , )A b c

( )b c

,max ( |, )1

b cb c gP

( )G f

( , )D a b

( , )F b c ( , )A b c

maxc

( )b c

Give the detailGive the detail