machine intelligence thomas d. nielsen september...

78
Bayesian networks: basics Machine Intelligence Thomas D. Nielsen September 2008 Bayesian networks: basics September 2008 1 / 25

Upload: others

Post on 20-Jan-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Bayesian networks: basicsMachine Intelligence

Thomas D. Nielsen

September 2008

Bayesian networks: basics September 2008 1 / 25

Page 2: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Message Passing in Join Trees

More sophisticated inference technique; used in most implemented Bayesian Network systems(e.g. Hugin).

Overview:

Given: Bayesian network for P(V)

⇓ Preprocessing

Construct a new internal representation for P(V) called a junction tree

⇓ Inference/Updating

Retrieve P(A | E = e) for single A ∈ V

Bayesian networks: basics September 2008 2 / 25

Page 3: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Calculate a marginal

P(A4)

=X

A1

X

A2

X

A3

X

A5

X

A6

φ1(A1)φ2(A2,A1)φ3(A3,A1)φ4(A4,A2)φ5(A5,A2,A3)φ6(A6,A3)

Bayesian networks: basics September 2008 3 / 25

Page 4: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Calculate a marginal

P(A4)

=X

A1

X

A2

X

A3

X

A5

X

A6

φ1(A1)φ2(A2,A1)φ3(A3,A1)φ4(A4,A2)φ5(A5,A2,A3)φ6(A6,A3)

=X

A1

φ1(A1)X

A2

φ2(A2,A1)φ4(A4,A2)X

A3

φ3(A3,A1)X

A5

φ5(A5,A2,A3)X

A6

φ6(A6,A3)

Bayesian networks: basics September 2008 3 / 25

Page 5: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Calculate a marginal

P(A4)=P

A1φ1(A1)

P

A2φ2(A2,A1)φ4(A4,A2)

P

A3φ3(A3,A1)

P

A5φ5(A5,A2,A3)

P

A6φ6(A6,A3)

Bayesian networks: basics September 2008 4 / 25

Page 6: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Calculate a marginal

Some of the calculations canbe simplified. E.g.

X

A6

P(A6 |A3) = 1

P(A4)=P

A1φ1(A1)

P

A2φ2(A2,A1)φ4(A4,A2)

P

A3φ3(A3,A1)

P

A5φ5(A5,A2,A3)

P

A6φ6(A6,A3)

Bayesian networks: basics September 2008 4 / 25

Page 7: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Calculate a marginal

Assume evidence e = (e5, e6); represented as 0/1 potentials. Then:

P(A4, e) =X

A1

φ1(A1)X

A2

φ2(A2,A1)φ4(A4,A2)

X

A3

φ3(A3,A1)X

A5

φ5(A5,A2,A3)e5

X

A6

φ6(A6,A3)e6

and

P(A4 | e) =P(A4, e)

P

A4P(A4, e)

Bayesian networks: basics September 2008 5 / 25

Page 8: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Calculate a marginal

Assume evidence e = (e5, e6); represented as 0/1 potentials. Then:

P(A4, e) =X

A1

φ1(A1)X

A2

φ2(A2,A1)φ4(A4,A2)

X

A3

φ3(A3,A1)X

A5

φ5(A5,A2,A3)e5

X

A6

φ6(A6,A3)e6

and

P(A4 | e) =P(A4, e)

P

A4P(A4, e)

The process is sufficiently general to handle all evidence scenarios!

⇒ We look for a general structure in which these calculations can be performed for all variables.

Bayesian networks: basics September 2008 5 / 25

Page 9: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Domain graphs

The Bayesian network The domain graph

The link (A2,A3) is called a moral link.

Bayesian networks: basics September 2008 6 / 25

Page 10: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Domain graphs

Moralization in general

For all nodes X : Connect pairwise all parents of X with undirected links.

Replace all original directed links by undirected ones.

1 2

3 4

765

8

The Bayesian network

Bayesian networks: basics September 2008 7 / 25

Page 11: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Domain graphs

Moralization in general

For all nodes X : Connect pairwise all parents of X with undirected links.

Replace all original directed links by undirected ones.

1 2

3 4

765

8

The Bayesian network

1 2

3 4

765

8

Step 1

Bayesian networks: basics September 2008 7 / 25

Page 12: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Domain graphs

Moralization in general

For all nodes X : Connect pairwise all parents of X with undirected links.

Replace all original directed links by undirected ones.

1 2

3 4

765

8

The Bayesian network

1 2

3 4

765

8

Step 1

1 2

3 4

765

8

Step 2

Bayesian networks: basics September 2008 7 / 25

Page 13: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Eliminating a variable

Suppose that when calculating P(A4) we start off by eliminating A3:

φ′(A1,A2,A5,A6) =X

A3

φ3(A3,A1)φ6(A6,A3)φ5(A5,A2,A3).

Graphically:

The Bayesian network The domain graph The new domain graph

Bayesian networks: basics September 2008 8 / 25

Page 14: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Eliminating a variable

Suppose that when calculating P(A4) we start off by eliminating A3:

φ′(A1,A2,A5,A6) =X

A3

φ3(A3,A1)φ6(A6,A3)φ5(A5,A2,A3).

Graphically:

The Bayesian network The domain graph The new domain graph

Perfect elimination sequences

If all variables can be eliminated without introducing fill-in edges, then the elimination sequence iscalled perfect. An example could be A5,A6,A3,A1,A2,A4.

Bayesian networks: basics September 2008 8 / 25

Page 15: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Perfect elimination sequences

Perfect elimination sequences

All perfect elimination sequences produce the same domain set, namely the set of cliques of thedomain graph.

Clique

A set of nodes is complete if all nodes are pairwise linked. A complete set is a clique if it is not asubset of another complete set.

1 2

3 4

765

8

Property

Any perfect elimination sequence ending with A is optimal w.r.t. calculating P(A).

Bayesian networks: basics September 2008 9 / 25

Page 16: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulated graphs

Definition

An undirected graph with a perfect elimination sequence is called a triangulated graph.

Example

not triangulated

triangulated

Bayesian networks: basics September 2008 10 / 25

Page 17: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulated graphs

Definition

An undirected graph with a perfect elimination sequence is called a triangulated graph.

Example

not triangulated

triangulated

Corollary

A graph is triangulated iff all nodes can successively be eliminated without introducing fill-in edges.

Bayesian networks: basics September 2008 10 / 25

Page 18: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulated graphs

Definition

An undirected graph with a perfect elimination sequence is called a triangulated graph.

Example

not triangulated

triangulated

Corollary

A graph is triangulated iff there does not exist a cycle of length ≥ 4 that is not cut by a cord.

Bayesian networks: basics September 2008 10 / 25

Page 19: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulated graphs

Definition

An undirected graph with a perfect elimination sequence is called a triangulated graph.

Example

not triangulated

triangulated

Corollary

In a triangulated graph, each variable A has a perfect elimination sequence ending with A.

Bayesian networks: basics September 2008 10 / 25

Page 20: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulated graphs

Definition

An undirected graph with a perfect elimination sequence is called a triangulated graph.

Example

not triangulated

triangulated

Assumption

For now we shall assume that the domain graph is triangulated!

Bayesian networks: basics September 2008 10 / 25

Page 21: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Join Tree (Junction Tree)

Let G be the set of cliques from an undirected graph, and let the cliques of G be organized in a treeT . Then T is a join tree if

a variable V that is contained in two nodes C,C′ also is contained in every node on the(unique) path connecting C and C′.

Example:

Bayesian networks: basics September 2008 11 / 25

Page 22: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Join Tree (Junction Tree)

Let G be the set of cliques from an undirected graph, and let the cliques of G be organized in a treeT . Then T is a join tree if

a variable V that is contained in two nodes C,C′ also is contained in every node on the(unique) path connecting C and C′.

Example:

(a) A join tree

(b) Not a join tree

Bayesian networks: basics September 2008 11 / 25

Page 23: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Join Tree (Junction Tree)

Let G be the set of cliques from an undirected graph, and let the cliques of G be organized in a treeT . Then T is a join tree if

a variable V that is contained in two nodes C,C′ also is contained in every node on the(unique) path connecting C and C′.

Example:

(a) A join tree

(b) Not a join tree

Theorem: An undirected graph G is triangulated if and only if the cliques of G can be organized ina join tree.

Bayesian networks: basics September 2008 11 / 25

Page 24: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From undirected graph to join graph

Define undirected graph (C, E∗):

C : Set of cliques in triangulated moral graphE∗ : {(C1,C2) | C1 ∩ C2 6= ∅}

Bayesian networks: basics September 2008 12 / 25

Page 25: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From undirected graph to join graph

Define undirected graph (C, E∗):

C : Set of cliques in triangulated moral graphE∗ : {(C1,C2) | C1 ∩ C2 6= ∅}

1 2

3 4

765

8

Bayesian networks: basics September 2008 12 / 25

Page 26: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From undirected graph to join graph

Define undirected graph (C, E∗):

C : Set of cliques in triangulated moral graphE∗ : {(C1,C2) | C1 ∩ C2 6= ∅}

1 2

3 4

765

8

Bayesian networks: basics September 2008 12 / 25

Page 27: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From undirected graph to join graph

Define undirected graph (C, E∗):

C : Set of cliques in triangulated moral graphE∗ : {(C1,C2) | C1 ∩ C2 6= ∅}

1 2

3 4

765

8

Bayesian networks: basics September 2008 12 / 25

Page 28: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From undirected graph to join graph

Define undirected graph (C, E∗):

C : Set of cliques in triangulated moral graphE∗ : {(C1,C2) | C1 ∩ C2 6= ∅}

1 2

3 4

765

8 5,6,7,8

1,2,3 2,4,7

3,6,72,3,7

Bayesian networks: basics September 2008 12 / 25

Page 29: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From join graph to join tree

Find maximal spanning tree: for edge e = (C1,C2) define weight w(e) := |C1 ∩ C2|. Let (C, E) bea maximal spanning tree of (C, E∗) with respect to edge weights.

Bayesian networks: basics September 2008 13 / 25

Page 30: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From join graph to join tree

Find maximal spanning tree: for edge e = (C1,C2) define weight w(e) := |C1 ∩ C2|. Let (C, E) bea maximal spanning tree of (C, E∗) with respect to edge weights.

5,6,7,8

1,2,3 2,4,7

3,6,72,3,7

Bayesian networks: basics September 2008 13 / 25

Page 31: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From join graph to join tree

Find maximal spanning tree: for edge e = (C1,C2) define weight w(e) := |C1 ∩ C2|. Let (C, E) bea maximal spanning tree of (C, E∗) with respect to edge weights.

1,2,3 2,4,7

3,6,72,3,7

5,6,7,8

1

1

1

2 2

2

2

1

Bayesian networks: basics September 2008 13 / 25

Page 32: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From join graph to join tree

Find maximal spanning tree: for edge e = (C1,C2) define weight w(e) := |C1 ∩ C2|. Let (C, E) bea maximal spanning tree of (C, E∗) with respect to edge weights.

1

1,2,3 2,4,7

3,6,72,3,7

5,6,7,8

1

1

1

2 2

2

2

Bayesian networks: basics September 2008 13 / 25

Page 33: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

From join graph to join tree

Find maximal spanning tree: for edge e = (C1,C2) define weight w(e) := |C1 ∩ C2|. Let (C, E) bea maximal spanning tree of (C, E∗) with respect to edge weights.

1,2,3 2,4,7

3,6,72,3,7

5,6,7,8

Bayesian networks: basics September 2008 13 / 25

Page 34: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

Another example

Bayesian networks: basics September 2008 14 / 25

Page 35: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

Another example

A1

A2 A3

A4 A5 A6

Bayesian networks: basics September 2008 14 / 25

Page 36: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

Another example

A1

A2 A3

A4 A5 A6

11

1 1

2A2,A4

A1,A2,A3

A2,A3,A5

A2,A3,A5

Bayesian networks: basics September 2008 14 / 25

Page 37: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Join tree construction

Another example

A1

A2 A3

A4 A5 A6

11

1 1

2A2,A4

A1,A2,A3

A2,A3,A5

A2,A3,A5

A2,A4

A1,A2,A3

A2,A3,A5

A2,A3,A5

Bayesian networks: basics September 2008 14 / 25

Page 38: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Junction tree construction

Correctness

Let (V,→) be a triangulated graph, (C, E∗). Every maximal spanning tree (C, E) of (C, E∗) is a jointree for V (Jensen,Jensen 1994).

If (V,→) is the triangulated moral graph of a Bayesian network, then there exists for every V ∈ V aclique C ∈ C with {V} ∪ pa(V ) ⊆ C.

Bayesian networks: basics September 2008 15 / 25

Page 39: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Initialization

Let T be a join tree for the domain graph G with potentials Φ. A junction tree for G consists of Twith the additions:

each potential φ from Φ is assigned to a clique containing dom (φ).

each link has a separator attached.

each separator contains two mailboxes, one for each direction.

Example

Bayesian networks: basics September 2008 16 / 25

Page 40: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Propagation

To calculate P(A4) we find a clique (V6) containing A4 and send messages to that clique.

Example

V4 : A1,A2,A3

↓ ↓

S4 : A2 S2 : A2,A3 S1 : A3

V6 : A2,A4 V2 : A2,A3,A5 V1 : A3,A6

φ1, φ2, φ3

φ4 φ5 φ6

↑ ↑ ↑ψ4

ψ2 = φ↓S25 ψ1 = φ

↓S16

Bayesian networks: basics September 2008 17 / 25

Page 41: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Propagation

To calculate P(A4) we find a clique (V6) containing A4 and send messages to that clique.

Example

1 : ψ1 = φ↓S16

↑1 : ψ2 = φ

↓S25

V4 : A1,A2,A3

↓ ↓

S4 : A2 S2 : A2,A3 S1 : A3

V6 : A2,A4 V2 : A2,A3,A5 V1 : A3,A6

φ1, φ2, φ3

φ4 φ5 φ6

↑ ↑

Bayesian networks: basics September 2008 17 / 25

Page 42: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Propagation

To calculate P(A4) we find a clique (V6) containing A4 and send messages to that clique.

Example

↑ ↑ ↑1 : ψ1 = φ

↓S161 : ψ2 = φ

↓S25

V4 : A1,A2,A3

↓ ↓

S4 : A2 S2 : A2,A3 S1 : A3

V6 : A2,A4 V2 : A2,A3,A5 V1 : A3,A6

φ1, φ2, φ3

φ4 φ5 φ6

2 : ψ4 = . . .

ψ4 =P

A1φ1φ2

P

A3φ3ψ1ψ2

Now evidence has been collected to V4 and we get P(A4) =P

A2φ4ψ4.

Bayesian networks: basics September 2008 17 / 25

Page 43: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Propagation

To calculate P(Ai ) for any Ai we send messages away from V6.

Example continued

↑ ↑ ↑1 : ψ1 = φ

↓S161 : ψ2 = φ

↓S25

V4 : A1,A2,A3

↓ ↓

S4 : A2 S2 : A2,A3 S1 : A3

V6 : A2,A4 V2 : A2,A3,A5 V1 : A3,A6

φ1, φ2, φ3

φ4 φ5 φ6

2 : ψ4 = . . .

ψ4 =P

A1φ1φ2

P

A3φ3ψ1ψ2

Bayesian networks: basics September 2008 18 / 25

Page 44: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Propagation

To calculate P(Ai ) for any Ai we send messages away from V6.

Example continued

φ6

↑ ↑ ↑1 : ψ1 = φ

↓S161 : ψ2 = φ

↓S25

V4 : A1,A2,A3

↓ ↓

S4 : A2 S2 : A2,A3 S1 : A3

V6 : A2,A4 V2 : A2,A3,A5 V1 : A3,A6

φ1, φ2, φ3

φ4 φ5

2 : ψ4 = . . .

3 : ψ4 = φ↓A24

Bayesian networks: basics September 2008 18 / 25

Page 45: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Propagation

To calculate P(Ai ) for any Ai we send messages away from V6.

Example continued

φ5V6 : A2,A4 V2 : A2,A3,A5 V1 : A3,A6

φ1, φ2, φ3

φ4 φ6

↑ ↑ ↑1 : ψ1 = φ

↓S161 : ψ2 = φ

↓S25

V4 : A1,A2,A3

↓ ↓

S4 : A2 S2 : A2,A3 S1 : A3

4 : ψ2 = . . . 4 : ψ1 = . . .

ψ2 =P

A1ψ1φ1φ2φ3ψ

4 ∼ {ψ4,P

A1φ1φ2φ3, ψ1}

ψ1 =P

A2ψ2ψ4

P

A1φ1φ2φ3

2 : ψ4 = . . .

3 : ψ4 = φ↓A24

Bayesian networks: basics September 2008 18 / 25

Page 46: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

In general: Sending a message from C i to C j

CiCj

Cl

Cm

mij

mli

mmi

mij :=X

Cj\Ci

Y

φ∈ΦCi

φY

Ck∈nd(Ci )

mki

Bayesian networks: basics September 2008 19 / 25

Page 47: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Messages passing in general

R

Collect and distribute messages

i) Collect messages to a preselected root R

Bayesian networks: basics September 2008 20 / 25

Page 48: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Messages passing in general

R

1

11

Collect and distribute messages

i) Collect messages to a preselected root R

Bayesian networks: basics September 2008 20 / 25

Page 49: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Messages passing in general

R2

1

1

2

1

Collect and distribute messages

i) Collect messages to a preselected root R

Bayesian networks: basics September 2008 20 / 25

Page 50: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Messages passing in general

R2

1

1

2

1

3

3

Collect and distribute messages

i) Collect messages to a preselected root R

ii) Distribute messages away from the root R

Bayesian networks: basics September 2008 20 / 25

Page 51: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Messages passing in general

42

1

1

2

1

R

3

4

3

4

Collect and distribute messages

i) Collect messages to a preselected root R

ii) Distribute messages away from the root R

Bayesian networks: basics September 2008 20 / 25

Page 52: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Theorem

Let the junction tree T represent the Bayesian network BN over the universe U and with evidencee. Assume that T is full.

1 Let V be a clique with set of potentials ΦV , and let S1, . . . ,Sk be V ’s neighboring separatorsand with V -directed messages Ψ1, . . . ,Ψk . Then

P(V , e) =Y

ΦV

Y

Ψ1 · . . . ·Y

Ψk .

2 Let S be a separator with the sets ΨS and ΨS in the mailboxes. Then

P(S, e) =Y

ΨS

Y

ΨS.

Bayesian networks: basics September 2008 21 / 25

Page 53: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Propagation in junction trees

Theorem

Let the junction tree T represent the Bayesian network BN over the universe U and with evidencee. Assume that T is full.

1 Let V be a clique with set of potentials ΦV , and let S1, . . . ,Sk be V ’s neighboring separatorsand with V -directed messages Ψ1, . . . ,Ψk . Then

P(V , e) =Y

ΦV

Y

Ψ1 · . . . ·Y

Ψk .

2 Let S be a separator with the sets ΨS and ΨS in the mailboxes. Then

P(S, e) =Y

ΨS

Y

ΨS.

Evidence

Evidence is inserted by adding corresponding 0/1-potentials to the appropriate cliques.

Bayesian networks: basics September 2008 21 / 25

Page 54: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

So far we have assumed that the domain graph is triangulated. If this is not the case, then weembed it in a triangulated graph.

Example

Bayesian networks: basics September 2008 22 / 25

Page 55: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

So far we have assumed that the domain graph is triangulated. If this is not the case, then weembed it in a triangulated graph.

Example

A triangulated graph extending (b)

Bayesian networks: basics September 2008 22 / 25

Page 56: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

Usually there are many possible triangulations and finding the best one is NP-hard!

Bayesian networks: basics September 2008 23 / 25

Page 57: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 58: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8 8

1 2

3 4

765

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 59: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8 8

1 2

3 4

765

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 60: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 61: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 62: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 63: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 64: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 65: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 66: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Triangulation of graphs

1 2

3 4

765

8

1 2

3 4

765

8

A heuristic

Repeatedly eliminate a simplicial node, and if this is not possible eliminate a node minimizing(fa(X) are noneliminated neighbors of X ):

|fa(X)| (fill-in-size ).| sp(fa(X)) | (clique-size).P

{Y ,Z}:{Y ,Z}∈nb(X)∧Z 6∈nb(Y ) | sp({Y , Z}) | (fill-in-weight)

Eliminating a node

Make all its noneliminated neighbors complete and remove the node.Bayesian networks: basics September 2008 23 / 25

Page 67: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Summary

1 2

3 4

765

8

Bayesian network

Bayesian networks: basics September 2008 24 / 25

Page 68: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Summary

1 2

3 4

765

8

1 2

3 4

765

8

Bayesian network Moral graph

Bayesian networks: basics September 2008 24 / 25

Page 69: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Summary

1 2

3 4

765

8

1 2

3 4

765

8

1 2

3 4

765

8

Bayesian network Moral graph Triangulated graph

Bayesian networks: basics September 2008 24 / 25

Page 70: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Summary

1 2

3 4

765

8

1 2

3 4

765

8

1 2

3 4

765

8

Bayesian network Moral graph Triangulated graph

5,6,7,8

1,2,3 2,4,7

3,6,72,3,7

Join graph

Bayesian networks: basics September 2008 24 / 25

Page 71: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Summary

1 2

3 4

765

8

1 2

3 4

765

8

1 2

3 4

765

8

Bayesian network Moral graph Triangulated graph

5,6,7,8

1,2,3 2,4,7

3,6,72,3,7

1,2,3 2,4,7

3,6,72,3,7

5,6,7,8

Join graph Join tree

Bayesian networks: basics September 2008 24 / 25

Page 72: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Summary

1 2

3 4

765

8

1 2

3 4

765

8

1 2

3 4

765

8

Bayesian network Moral graph Triangulated graph

5,6,7,8

1,2,3 2,4,7

3,6,72,3,7

1,2,3 2,4,7

3,6,72,3,7

5,6,7,8

6,7

1,2,3 2,4,7

3,6,72,3,7

5,6,7,8

2,3 2,7

3,7

Join graph Join tree Junction tree

Bayesian networks: basics September 2008 24 / 25

Page 73: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Summary

Given: Bayesian network BN for P(V)

Bayesian networks: basics September 2008 25 / 25

Page 74: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Summary

Given: Bayesian network BN for P(V)

⇓ Moralize

Domain graph G for BN (also called the moral graph)

Bayesian networks: basics September 2008 25 / 25

Page 75: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Summary

Given: Bayesian network BN for P(V)

⇓ Moralize

Domain graph G for BN (also called the moral graph)

⇓ Triangulate

Triangulated graph for G

Bayesian networks: basics September 2008 25 / 25

Page 76: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Summary

Given: Bayesian network BN for P(V)

⇓ Moralize

Domain graph G for BN (also called the moral graph)

⇓ Triangulate

Triangulated graph for G

⇓ Find cliques

Join graph

Bayesian networks: basics September 2008 25 / 25

Page 77: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Summary

Given: Bayesian network BN for P(V)

⇓ Moralize

Domain graph G for BN (also called the moral graph)

⇓ Triangulate

Triangulated graph for G

⇓ Find cliques

Join graph

⇓ Find maximal spanning tree

Join tree

Bayesian networks: basics September 2008 25 / 25

Page 78: Machine Intelligence Thomas D. Nielsen September 2008people.cs.aau.dk/.../junction-tree-propagation.pdf · Construct a new internal representation for P(V) called a junction tree

Exact Inference

Summary

Given: Bayesian network BN for P(V)

⇓ Moralize

Domain graph G for BN (also called the moral graph)

⇓ Triangulate

Triangulated graph for G

⇓ Find cliques

Join graph

⇓ Find maximal spanning tree

Join tree

Perform belief updating by message passing.

Bayesian networks: basics September 2008 25 / 25