23
CS421: Intro to AI 1 Hal Daumé III ([email protected]) Bayes Nets II: Independence Day Hal Daumé III Computer Science University of Maryland [email protected] CS 421: Introduction to Artificial Intelligence 5 Apr 2012 Many slides courtesy of Dan Klein, Stuart Russell, or Andrew Moore

Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI1 Hal Daumé III ([email protected])

Bayes Nets II:Independence Day

Hal Daumé IIIComputer ScienceUniversity of Maryland

[email protected]

CS 421: Introduction to Artificial Intelligence

5 Apr 2012Many slides courtesy of

Dan Klein, Stuart Russell,or Andrew Moore

Page 2: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI2 Hal Daumé III ([email protected])

Announcements

➢ HW07 bug➢ If you did the full thing, great➢ If not, that's fine too

➢ P2 results have been sent, please complain now :)➢ Midterms will be returned on Tuesday

➢ Solution is posted online➢ Let me know if you find bugs :)

Page 3: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI3 Hal Daumé III ([email protected])

Bayes’ Nets

➢ So far:➢ What is a Bayes’ net?➢ What joint distribution does it encode?

➢ Next: how to answer queries about that distribution➢ Key idea: conditional independence➢ Last class: assembled BNs using an intuitive notion of

conditional independence as causality➢ Today: formalize these ideas➢ Main goal: answer queries about conditional independence

and influence

➢ After that: how to answer numerical queries (inference)

Page 4: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI4 Hal Daumé III ([email protected])

Conditional Independence

➢ Reminder: independence➢ X and Y are independent if

➢ X and Y are conditionally independent given Z

➢ (Conditional) independence is a property of a distribution

Page 5: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI5 Hal Daumé III ([email protected])

Example: Independence

➢ For this graph, you can fiddle with θ (the CPTs) all you want, but you won’t be able to represent any distribution in which the flips are dependent!

h 0.5t 0.5

h 0.5t 0.5

X1 X2

All distributions

Page 6: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI6 Hal Daumé III ([email protected])

Topology Limits Distributions

➢ Given some graph topology G, only certain joint distributions can be encoded

➢ The graph structure guarantees certain (conditional) independences

➢ (There might be more independence)

➢ Adding arcs increases the set of distributions, but has several costs

X

Y

Z

X

Y

Z

X

Y

Z

Page 7: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI7 Hal Daumé III ([email protected])

Independence in a BN

➢ Important question about a BN:➢ Are two nodes independent given certain evidence?➢ If yes, can calculate using algebra (really tedious)➢ If no, can prove with a counter example➢ Example:

➢ Question: are X and Z independent?➢ Answer: not necessarily, we’ve seen examples otherwise: low

pressure causes rain which causes traffic.➢ X can influence Z, Z can influence X (via Y)➢ Addendum: they could be independent: how?

X Y Z

Page 8: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI8 Hal Daumé III ([email protected])

Causal Chains

➢ This configuration is a “causal chain”

➢ Is X independent of Z given Y?

➢ Evidence along the chain “blocks” the influence

X Y Z

Yes!

X: Low pressure

Y: Rain

Z: Traffic

Page 9: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI9 Hal Daumé III ([email protected])

Common Cause

➢ Another basic configuration: two effects of the same cause

➢ Are X and Z independent?

➢ Are X and Z independent given Y?

➢ Observing the cause blocks influence between effects.

X

Y

Z

Yes!

Y: Project due

X: Email busy

Z: Lab full

Page 10: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI10 Hal Daumé III ([email protected])

Common Effect

➢ Last configuration: two causes of one effect (v-structures)

➢ Are X and Z independent?➢ Yes: remember the ballgame and the rain causing

traffic, no correlation?➢ Still need to prove they must be (try it!)

➢ Are X and Z independent given Y?➢ No: remember that seeing traffic put the rain and

the ballgame in competition?

➢ This is backwards from the other cases➢ Observing the effect enables influence between

effects.

X

Y

Z

X: Raining

Z: Ballgame

Y: Traffic

Page 11: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI11 Hal Daumé III ([email protected])

The General Case

➢ Any complex example can be analyzed using these three canonical cases

➢ General question: in a given BN, are two variables independent (given evidence)?

➢ Solution: analyze the graph

Page 12: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI12 Hal Daumé III ([email protected])

Reachability

➢ Recipe: shade evidence nodes

➢ Attempt 1: if two nodes are connected by an undirected path not blocked by a shaded node, they are conditionally independent

➢ Almost works, but not quite➢ Where does it break?➢ Answer: the v-structure at T doesn’t count

as a link in a path unless “active”

R

T

B

D

L

T’

Page 13: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI13 Hal Daumé III ([email protected])

Reachability (the Bayes’ Ball)

➢ Correct algorithm:➢ Shade in evidence➢ Start at source node➢ Try to reach target by search➢ States: pair of (node X, previous

state S)➢ Successor function:

➢ X unobserved:➢ To any child➢ To any parent if coming from a

child➢ X observed:

➢ From parent to parent➢ If you can’t reach a node, it’s

conditionally independent of the start node given evidence

S

X X

S

S

X X

S

Page 14: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI14 Hal Daumé III ([email protected])

Reachability (D-Separation)

➢ Question: Are X and Y conditionally independent given evidence variables {Z}?

➢ Look for “active paths” from X to Y

➢ No active paths = independence!

➢ A path is active if each triple is either a:

➢ Causal chain A → B → C where B is unobserved (either direction)

➢ Common cause A ← B → C where B is unobserved

➢ Common effect (aka v-structure)A → B ← C where B or one of its descendents is observed

Active Triples Inactive Triples

Page 15: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI15 Hal Daumé III ([email protected])

Example

Yes

Page 16: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI16 Hal Daumé III ([email protected])

Example

R

T

B

D

L

T’

Yes

Yes

Yes

Page 17: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI17 Hal Daumé III ([email protected])

Example

➢ Variables:➢ R: Raining➢ T: Traffic➢ D: Roof drips➢ S: I’m sad

➢ Questions:T

S

D

R

Yes

Page 18: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI18 Hal Daumé III ([email protected])

Causality?

➢ When Bayes’ nets reflect the true causal patterns:➢ Often simpler (nodes have fewer parents)➢ Often easier to think about➢ Often easier to elicit from experts

➢ BNs need not actually be causal➢ Sometimes no causal net exists over the domain➢ E.g. consider the variables Traffic and Drips➢ End up with arrows that reflect correlation, not causation

➢ What do the arrows really mean?➢ Topology may happen to encode causal structure➢ Topology only guaranteed to encode conditional

independence

Page 19: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI19 Hal Daumé III ([email protected])

Example: Traffic

➢ Basic traffic net➢ Let’s multiply out the joint

R

T

r 1/4

¬r 3/4

r t 3/4

¬t 1/4

¬r t 1/2

¬t 1/2

r t 3/16 r ¬t 1/16

¬r t 6/16

¬r ¬t 6/16

Page 20: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI20 Hal Daumé III ([email protected])

Example: Reverse Traffic

➢ Reverse causality?

T

R

t 9/16

¬t 7/16

t r 1/3

¬r 2/3

¬t r 1/7

¬r 6/7

r t 3/16 r ¬t 1/16

¬r t 6/16

¬r ¬t 6/16

Page 21: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI21 Hal Daumé III ([email protected])

Example: Coins

➢ Extra arcs don’t prevent representing independence, just allow non-independence

h 0.5t 0.5

h 0.5t 0.5

X1 X2

h 0.5t 0.5

h | h 0.5t | h 0.5

X1 X2

h | t 0.5t | t 0.5

Page 22: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI22 Hal Daumé III ([email protected])

Alternate BNs

Page 23: Bayes Nets II: Independence Day - University Of Marylandusers.umiacs.umd.edu/.../cs421-day16-bayesnets2.pdf · Bayes nets compactly encode joint distributions Guaranteed independencies

CS421: Intro to AI23 Hal Daumé III ([email protected])

Summary

➢ Bayes nets compactly encode joint distributions

➢ Guaranteed independencies of distributions can be deduced from BN graph structure

➢ The Bayes’ ball algorithm (aka d-separation)

➢ A Bayes’ net may have other independencies that are not detectable until you inspect its specific distribution