Upcoming SlideShare
×

# Cs221 lecture3-fall11

319 views

Published on

Published in: Technology, Education
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
319
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
9
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Cs221 lecture3-fall11

1. 1. CS 221: Artificial Intelligence Lecture 3: Probability and Bayes Nets Sebastian Thrun and Peter Norvig Naranbaatar Bayanbat, Juthika Dabholkar, Carlos Fernandez-Granda, Yan Largman, Cameron Schaeffer, Matthew Seal Slide Credit: Dan Klein (UC Berkeley)
2. 2. Goal of Today <ul><li>Structured representation of probability distribution </li></ul>
3. 3. Probability <ul><li>Expresses uncertainty </li></ul><ul><li>Pervasive in all of AI </li></ul><ul><ul><li>Machine learning </li></ul></ul><ul><ul><li>Information Retrieval (e.g., Web) </li></ul></ul><ul><ul><li>Computer Vision </li></ul></ul><ul><ul><li>Robotics </li></ul></ul><ul><li>Based on mathematical calculus </li></ul><ul><li>Disclaimer: We only discuss finite distributions </li></ul>
4. 4. Probability <ul><li>Probability of a fair coin </li></ul>
5. 5. Probability <ul><li>Probability of cancer </li></ul>
6. 6. Joint Probability <ul><li>Multiple events: cancer, test result </li></ul>Has cancer? Test positive? P(C,TP) yes yes 0.018 yes no 0.002 no yes 0.196 no no 0.784
7. 7. Joint Probability <ul><li>The problem with joint distributions </li></ul><ul><li>It takes 2 D -1 numbers to specify them! </li></ul>
8. 8. Conditional Probability <ul><li>Describes the cancer test: </li></ul><ul><li>Put this together with: Prior probability </li></ul>
9. 9. Conditional Probability <ul><li>We have: </li></ul><ul><li>We can now calculate joint probabilities </li></ul>Has cancer? Test positive? P(TP, C) yes yes yes no no yes no no Has cancer? Test positive? P(TP, C) yes yes 0.018 yes no 0.002 no yes 0.196 no no 0.784
10. 10. Conditional Probability <ul><li>“ Diagnostic” question: How likely do is cancer given a positive test? </li></ul>Has cancer? Test positive? P(TP, C) yes yes 0.018 yes no 0.002 no yes 0.196 no no 0.784
11. 11. Bayes Network <ul><li>We just encountered our first Bayes network: </li></ul>Cancer Test positive P(cancer) and P(Test positive | cancer) is called the “model” Calculating P(Test positive) is called “prediction” Calculating P(Cancer | test positive) is called “diagnostic reasoning”
12. 12. Bayes Network <ul><li>We just encountered our first Bayes network: </li></ul>Cancer Test positive Cancer Test positive versus
13. 13. Independence <ul><li>Independence </li></ul><ul><li>What does this mean for our test? </li></ul><ul><ul><li>Don’t take it! </li></ul></ul>Cancer Test positive
14. 14. Independence <ul><li>Two variables are independent if: </li></ul><ul><ul><li>This says that their joint distribution factors into a product two simpler distributions </li></ul></ul><ul><ul><li>This implies: </li></ul></ul><ul><ul><li>We write: </li></ul></ul><ul><li>Independence is a simplifying modeling assumption </li></ul><ul><ul><li>Empirical joint distributions: at best “close” to independent </li></ul></ul>
15. 15. Example: Independence <ul><li>N fair, independent coin flips: </li></ul>h 0.5 t 0.5 h 0.5 t 0.5 h 0.5 t 0.5
16. 16. Example: Independence? T W P warm sun 0.4 warm rain 0.1 cold sun 0.2 cold rain 0.3 T W P warm sun 0.3 warm rain 0.2 cold sun 0.3 cold rain 0.2 T P warm 0.5 cold 0.5 W P sun 0.6 rain 0.4
17. 17. Conditional Independence <ul><li>P(Toothache, Cavity, Catch) </li></ul><ul><li>If I have a Toothache, a dental probe might be more likely to catch </li></ul><ul><li>But: if I have a cavity, the probability that the probe catches doesn't depend on whether I have a toothache: </li></ul><ul><ul><li>P(+catch | +toothache, +cavity) = P(+catch | +cavity) </li></ul></ul><ul><li>The same independence holds if I don ’t have a cavity: </li></ul><ul><ul><li>P(+catch | +toothache,  cavity) = P(+catch|  cavity) </li></ul></ul><ul><li>Catch is conditionally independent of Toothache given Cavity: </li></ul><ul><ul><li>P(Catch | Toothache, Cavity) = P(Catch | Cavity) </li></ul></ul><ul><li>Equivalent conditional independence statements: </li></ul><ul><ul><li>P(Toothache | Catch , Cavity) = P(Toothache | Cavity) </li></ul></ul><ul><ul><li>P(Toothache, Catch | Cavity) = P(Toothache | Cavity) P(Catch | Cavity) </li></ul></ul><ul><ul><li>One can be derived from the other easily </li></ul></ul><ul><li>We write: </li></ul>
18. 18. Bayes Network Representation Cavity Catch Toothache P(cavity) P(catch | cavity) P(toothache | cavity) 1 parameter 2 parameters 2 parameters Versus: 2 3 -1 = 7 parameters
19. 19. A More Realistic Bayes Network
20. 20. Example Bayes Network: Car
21. 21. Graphical Model Notation <ul><li>Nodes: variables (with domains) </li></ul><ul><ul><li>Can be assigned (observed) or unassigned (unobserved) </li></ul></ul><ul><li>Arcs: interactions </li></ul><ul><ul><li>Indicate “direct influence” between variables </li></ul></ul><ul><ul><li>Formally: encode conditional independence (more later) </li></ul></ul><ul><li>For now: imagine that arrows mean direct causation (they may not!) </li></ul>
22. 22. Example: Coin Flips <ul><li>N independent coin flips </li></ul><ul><li>No interactions between variables: absolute independence </li></ul>X 1 X 2 X n
23. 23. Example: Traffic <ul><li>Variables: </li></ul><ul><ul><li>R: It rains </li></ul></ul><ul><ul><li>T: There is traffic </li></ul></ul><ul><li>Model 1: independence </li></ul><ul><li>Model 2: rain causes traffic </li></ul><ul><li>Why is an agent using model 2 better? </li></ul>R T
24. 24. Example: Alarm Network <ul><li>Variables </li></ul><ul><ul><li>B: Burglary </li></ul></ul><ul><ul><li>A: Alarm goes off </li></ul></ul><ul><ul><li>M: Mary calls </li></ul></ul><ul><ul><li>J: John calls </li></ul></ul><ul><ul><li>E: Earthquake! </li></ul></ul>B urglary E arthquake A larm J ohn calls M ary calls
25. 25. Bayes Net Semantics <ul><li>A set of nodes, one per variable X </li></ul><ul><li>A directed, acyclic graph </li></ul><ul><li>A conditional distribution for each node </li></ul><ul><ul><li>A collection of distributions over X, one for each combination of parents ’ values </li></ul></ul><ul><ul><li>CPT: conditional probability table </li></ul></ul><ul><ul><li>Description of a noisy “causal” process </li></ul></ul>A 1 X A n A Bayes net = Topology (graph) + Local Conditional Probabilities
26. 26. Probabilities in BNs <ul><li>Bayes nets implicitly encode joint distributions </li></ul><ul><ul><li>As a product of local conditional distributions </li></ul></ul><ul><ul><li>To see what probability a BN gives to a full assignment, multiply all the relevant conditionals together: </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><li>This lets us reconstruct any entry of the full joint </li></ul><ul><li>Not every BN can represent every joint distribution </li></ul><ul><ul><li>The topology enforces certain conditional independencies </li></ul></ul>
27. 27. Example: Coin Flips X 1 X 2 X n Only distributions whose variables are absolutely independent can be represented by a Bayes ’ net with no arcs. h 0.5 t 0.5 h 0.5 t 0.5 h 0.5 t 0.5
28. 28. Example: Traffic R T +r 1/4  r 3/4 +r +t 3/4  t 1/4  r +t 1/2  t 1/2 R T joint +r +t 3/16 +r -t 1/16 -r +t 3/8 -r -t 3/8
29. 29. Example: Alarm Network B urglary E arthqk A larm J ohn calls M ary calls How many parameters? 1 1 4 2 2 10
30. 30. Example: Alarm Network B urglary E arthqk A larm J ohn calls M ary calls B P(B) +b 0.001  b 0.999 E P(E) +e 0.002  e 0.998 B E A P(A|B,E) +b +e +a 0.95 +b +e  a 0.05 +b  e +a 0.94 +b  e  a 0.06  b +e +a 0.29  b +e  a 0.71  b  e +a 0.001  b  e  a 0.999 A J P(J|A) +a +j 0.9 +a  j 0.1  a +j 0.05  a  j 0.95 A M P(M|A) +a +m 0.7 +a  m 0.3  a +m 0.01  a  m 0.99
31. 31. Example: Alarm Network B urglary E arthquake A larm J ohn calls M ary calls
32. 32. Bayes ’ Nets <ul><li>A Bayes ’ net is an </li></ul><ul><li>efficient encoding </li></ul><ul><li>of a probabilistic </li></ul><ul><li>model of a domain </li></ul><ul><li>Questions we can ask: </li></ul><ul><ul><li>Inference: given a fixed BN, what is P(X | e)? </li></ul></ul><ul><ul><li>Representation: given a BN graph, what kinds of distributions can it encode? </li></ul></ul><ul><ul><li>Modeling: what BN is most appropriate for a given domain? </li></ul></ul>
33. 33. Remainder of this Class <ul><li>Find Conditional (In)Dependencies </li></ul><ul><ul><li>Concept of “d-separation” </li></ul></ul>
34. 34. Causal Chains <ul><li>This configuration is a “causal chain” </li></ul><ul><ul><li>Is X independent of Z given Y? </li></ul></ul><ul><ul><li>Evidence along the chain “blocks” the influence </li></ul></ul>X Y Z Yes! X: Low pressure Y: Rain Z: Traffic
35. 35. Common Cause <ul><li>Another basic configuration: two effects of the same cause </li></ul><ul><ul><li>Are X and Z independent? </li></ul></ul><ul><ul><li>Are X and Z independent given Y? </li></ul></ul><ul><ul><li>Observing the cause blocks influence between effects. </li></ul></ul>X Y Z Yes! Y: Alarm X: John calls Z: Mary calls
36. 36. Common Effect <ul><li>Last configuration: two causes of one effect (v-structures) </li></ul><ul><ul><li>Are X and Z independent? </li></ul></ul><ul><ul><ul><li>Yes: the ballgame and the rain cause traffic, but they are not correlated </li></ul></ul></ul><ul><ul><ul><li>Still need to prove they must be (try it!) </li></ul></ul></ul><ul><ul><li>Are X and Z independent given Y? </li></ul></ul><ul><ul><ul><li>No: seeing traffic puts the rain and the ballgame in competition as explanation? </li></ul></ul></ul><ul><ul><li>This is backwards from the other cases </li></ul></ul><ul><ul><ul><li>Observing an effect activates influence between possible causes. </li></ul></ul></ul>X Y Z X: Raining Z: Ballgame Y: Traffic
37. 37. The General Case <ul><li>Any complex example can be analyzed using these three canonical cases </li></ul><ul><li>General question: in a given BN, are two variables independent (given evidence)? </li></ul><ul><li>Solution: analyze the graph </li></ul>
38. 38. Reachability <ul><li>Recipe: shade evidence nodes </li></ul><ul><li>Attempt 1: Remove shaded nodes. If two nodes are still connected by an undirected path, they are not conditionally independent </li></ul><ul><li>Almost works, but not quite </li></ul><ul><ul><li>Where does it break? </li></ul></ul><ul><ul><li>Answer: the v-structure at T doesn ’t count as a link in a path unless “active” </li></ul></ul>R T B D L
39. 39. Reachability (D-Separation) <ul><li>Question: Are X and Y conditionally independent given evidence vars {Z}? </li></ul><ul><ul><li>Yes, if X and Y “separated” by Z </li></ul></ul><ul><ul><li>Look for active paths from X to Y </li></ul></ul><ul><ul><li>No active paths = independence! </li></ul></ul><ul><li>A path is active if each triple is active: </li></ul><ul><ul><li>Causal chain A  B  C where B is unobserved (either direction) </li></ul></ul><ul><ul><li>Common cause A  B  C where B is unobserved </li></ul></ul><ul><ul><li>Common effect (aka v-structure) </li></ul></ul><ul><ul><li>A  B  C where B or one of its descendents is observed </li></ul></ul><ul><li>All it takes to block a path is a single inactive segment </li></ul>Active Triples Inactive Triples
40. 40. Example Yes R T B T ’
41. 41. Example R T B D L T ’ Yes Yes Yes
42. 42. Example <ul><li>Variables: </li></ul><ul><ul><li>R: Raining </li></ul></ul><ul><ul><li>T: Traffic </li></ul></ul><ul><ul><li>D: Roof drips </li></ul></ul><ul><ul><li>S: I ’m sad </li></ul></ul><ul><li>Questions: </li></ul>T S D R Yes
43. 43. A Common BN T 1 T 2 A T N T 3 … Unobservable cause Tests time Diagnostic Reasoning:
44. 44. A Common BN T 1 T 2 A T N T 3 … Unobservable cause Tests time Diagnostic Reasoning:
45. 45. A Common BN T 1 T 2 A T N T 3 … Unobservable cause Tests time Diagnostic Reasoning:
46. 46. A Common BN T 1 T 2 A T N T 3 … Unobservable cause Tests time Diagnostic Reasoning:
47. 47. Causality? <ul><li>When Bayes ’ nets reflect the true causal patterns: </li></ul><ul><ul><li>Often simpler (nodes have fewer parents) </li></ul></ul><ul><ul><li>Often easier to think about </li></ul></ul><ul><ul><li>Often easier to elicit from experts </li></ul></ul><ul><li>BNs need not actually be causal </li></ul><ul><ul><li>Sometimes no causal net exists over the domain </li></ul></ul><ul><ul><li>End up with arrows that reflect correlation, not causation </li></ul></ul><ul><li>What do the arrows really mean? </li></ul><ul><ul><li>Topology may happen to encode causal structure </li></ul></ul><ul><ul><li>Topology only guaranteed to encode conditional independence </li></ul></ul>
48. 48. Summary <ul><li>Bayes network: </li></ul><ul><ul><li>Graphical representation of joint distributions </li></ul></ul><ul><ul><li>Efficiently encode conditional independencies </li></ul></ul><ul><ul><li>Reduce number of parameters from exponential to linear (in many cases) </li></ul></ul><ul><ul><li>Thursday: Inference in (general) Bayes networks </li></ul></ul>