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
Bayesian NetworksBucket Elimination Algorithm
主講人:虞台文
大同大學資工所智慧型多媒體研究室
Content
Basic ConceptBelief UpdatingMost Probable Explanation (MPE)Maximum A Posteriori (MAP)
Bayesian NetworksBucket Elimination Algorithm
Basic Concept
大同大學資工所智慧型多媒體研究室
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?
Resolution
( ) ( )q q can be true if and only if
can be true.
q q ?TURE
unsatisfiable
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:
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?
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
Direct Resolution
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
Bucket Elimination
The algorithm will be used as a framework for various probabilistic inferences on Bayesian Networks.
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}.
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
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
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
Bayesian NetworksBucket Elimination Algorithm
Belief Updating
大同大學資工所智慧型多媒體研究室
Goal
( | ) ?X xP E e
( , )
( )
X xP
P
E e
E eNormalization
Factor
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
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
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
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
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
Basic Concept of Variable Elimination
1
( ) ( | )Gg
P g ff
f G(f )
+ 0.1
0.7
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
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
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
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
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
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?
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
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
Definition of Tree-Width
Goal: Finding an ordering with smallest induced width.
NP-Hard Greedy heuristic and Approximation methodsAre available.
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.
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?
Bayesian NetworksBucket Elimination Algorithm
Most Probable Explanation (MPE)
大同大學資工所智慧型多媒體研究室
MPE
Goal:
arg max ( | )* ?P x
X x E exevidence
1( , , )nx xx
arg max ( , ) ?* P x
exx
MPE
Goal:
arg max ( | )* ?P x
X x E ex
Notationsarg max (* , )P
xx ex
i
iF
xi
i
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
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
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
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.
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
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
Bucket Elimination Algorithm
Exercise, , , ,
, ,max ( 1) ?, , ,a b c d f
a b c gP d f
Consider ordering ACBFDG
Bayesian NetworksBucket Elimination Algorithm
Maximum A Posteriori (MAP)
大同大學資工所智慧型多媒體研究室
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
ExampleA
B
D
C
F
G
Hypothesis (Decision) Variables
,arg max ( | )*, * 1( ?) ,
b cc P c gbb
g = 1
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
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
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
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
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
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