Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bayesian networks Chapter 14. Outline Syntax Semantics.

Similar presentations


Presentation on theme: "Bayesian networks Chapter 14. Outline Syntax Semantics."— Presentation transcript:

1 Bayesian networks Chapter 14

2 Outline Syntax Semantics

3 Bayesian networks A simple, graphical notation for conditional independence assertions and hence for compact specification of full joint distributions Syntax: –a set of nodes, one per variable –a directed, acyclic graph (link ≈ "directly influences") –a conditional distribution for each node given its parents: P (X i | Parents (X i )) In the simplest case, conditional distribution represented as a conditional probability table (CPT) giving the distribution over X i for each combination of parent values

4 Example Topology of network encodes conditional independence assertions: Weather is independent of the other variables Toothache and Catch are conditionally independent given Cavity

5 Example I'm at work, neighbor John calls to say my alarm is ringing, but neighbor Mary doesn't call. Sometimes it's set off by minor earthquakes. Is there a burglar? Variables: Burglary, Earthquake, Alarm, JohnCalls, MaryCalls Network topology reflects "causal" knowledge: –A burglar can set the alarm off –An earthquake can set the alarm off –The alarm can cause Mary to call –The alarm can cause John to call

6 Example contd.

7 Compactness A CPT for Boolean X i with k Boolean parents has 2 k rows for the combinations of parent values Each row requires one number p for X i = true (the number for X i = false is just 1-p) If each variable has no more than k parents, the complete network requires O(n · 2 k ) numbers I.e., grows linearly with n, vs. O(2 n ) for the full joint distribution For burglary net, 1 + 1 + 4 + 2 + 2 = 10 numbers (vs. 2 5 -1 = 31)

8 Semantics The full joint distribution is defined as the product of the local conditional distributions: P (X 1, …,X n ) = π i = 1 P (X i | Parents(X i )) e.g., P(j  m  a   b   e) = P (j | a) P (m | a) P (a |  b,  e) P (  b) P (  e) n

9 Constructing Bayesian networks 1. Choose an ordering of variables X 1, …,X n 2. For i = 1 to n –add X i to the network –select parents from X 1, …,X i-1 such that P (X i | Parents(X i )) = P (X i | X 1,... X i-1 ) This choice of parents guarantees: P (X 1, …,X n ) = π i =1 P (X i | X 1, …, X i-1 ) (chain rule) = π i =1 P (X i | Parents(X i )) (by construction) n n

10 Suppose we choose the ordering M, J, A, B, E P(J | M) = P(J)? Example

11 Suppose we choose the ordering M, J, A, B, E P(J | M) = P(J) No P(A | J, M) = P(A | J)? P(A | J, M) = P(A)? Example

12 Suppose we choose the ordering M, J, A, B, E P(J | M) = P(J) No P(A | J, M) = P(A | J)? P(A | J, M) = P(A)? No P(B | A, J, M) = P(B | A)? P(B | A, J, M) = P(B)? Example

13 Suppose we choose the ordering M, J, A, B, E P(J | M) = P(J) No P(A | J, M) = P(A | J)? P(A | J, M) = P(A)? No P(B | A, J, M) = P(B | A)? Yes P(B | A, J, M) = P(B)? No P(E | B, A,J, M) = P(E | A)? P(E | B, A, J, M) = P(E | A, B)? Example

14 Suppose we choose the ordering M, J, A, B, E P(J | M) = P(J) No P(A | J, M) = P(A | J)? P(A | J, M) = P(A)? No P(B | A, J, M) = P(B | A)? Yes P(B | A, J, M) = P(B)? No P(E | B, A,J, M) = P(E | A)? No P(E | B, A, J, M) = P(E | A, B)? Yes Example

15 Example contd. Deciding conditional independence is hard in noncausal directions (Causal models and conditional independence seem hardwired for humans!) Network is less compact: 1 + 2 + 4 + 2 + 4 = 13 numbers needed

16 Inference Complexity of inference Bayes Net –Bayes Net reduces space complexity –Bayes Net does not reduce time complexity for general case

17 Conditional independence and D-separation Two sets of nodes, X and Y, are conditionally independent given an evidence set of nodes, E if every undirected path from a node in X to a node in Y is d-seperated by E. A set of nodes, E d-separates to sets of nodes, X and Y, if every undirected path from a node in X to a node in Y is blocked by E A path is blocked given E if there is a node Z on the path for which one of the following holds:

18 Conditional independence and D-separation - example

19 Inference Inference by enumeration P(B | j, m) = P(B, j, m) / P(j, m) =  P(B, j, m) =   a  e P(B, e, a, j, m) =  P(B)  e P(e)  a P(a | B,e) P(j | a) P(m | a) =  =

20 Enumeration algorithm

21 Time complexity Enumeration is inefficient (e.g., computes P(j|a)P(m|a) for each value of e) Dynamic programming (for example, by Variable Elimination)

22 Inference for polytrees

23 Time complexity Dynamic programming –Linear space and time complexity? –Works well for polytrees (where there is at most one path between any two nodes) –Doesn’t work for multiply connected networks (exponential space and time complexity on worst case)

24 Inference in multiply connected networks Clustering Cutset conditioning Stochastic methods –Monte Carlo –likelihood weighting –Markov Chain Monte Carlo Will be skipped in this course

25 Clustering Merge variables, replace their CPTs by their combined CPT

26 Cutset conditioning cutting off cycles to obtain polytree. Sum over all instantiations of cutset variables.

27 Cutset conditioning - example P(W|S) =  RC P(W|S,R,C) P(R,C|S) =  RC P(W|S,R) P(R,C|S) P(R,C|S) = P(R,S|C) P(C) / P(S) = P(R|C) P(S|C) P(C) / P(S) (Notice here that node C d-separates R and S) P(C = +)+ P(C = -)

28 Stochastic Inference It’s expensive to work with the full joint distribution… whether as a table or as a Bayes Network Is approximation good enough? Monte Carlo

29 Use samples to approximate solution –Simulated annealing used Monte Carlo theories to justify why random guesses and sometimes going uphill can lead to optimality More samples = better approximation –How many are needed? –Where should you take the samples?

30 Prior sampling An ability to model the prior probabilities of a set of random variables

31 Approximating true distribution With enough samples, perfect modeling is possible

32 Rejection sampling Compute P(X | e) –Use PriorSample (S PS ) and create N samples –Denote N e number of samples consistent with e (namely E = e) –Denote N ex number of samples consistent with E = e) AND X = x –P(X | e) can be computed from N ex / N e

33 Example –P(Rain | Sprinkler = true) –Use Bayes Net to generate 100 samples Suppose 73 have Sprinkler=false Suppose 27 have Sprinkler=true –8 have Rain=true –19 have Rain=false –P(Rain | Sprinkler=true) =

34 Problems with rejection sampling –Standard deviation of the error in probability is proportional to 1/sqrt(n), where n is the number of samples consistent with evidence –As problems become complex, number of samples consistent with evidence becomes small and it becomes harder to construct accurate estimates

35 Likelihood weighting We only want to generate samples that are consistent with the evidence, e –We’ll sample the Bayes Net, but we won’t let every random variable be sampled, some will be forced to produce a specific output

36 Example P (Rain | Sprinkler=true, WetGrass=true)

37 Example P (Rain | Sprinkler=true, WetGrass=true) –First, weight vector, w, set to 1.0

38 Example Notice that weight is reduced according to how likely an evidence variable’s output is given its parents –So final probability is a function of what comes from sampling the free variables while constraining the evidence variables

39 Comparing techniques –In likelihood weighting, attention is paid to evidence variables before samples are collected –In rejection sampling, evidence variables are considered after the sampling –Likelihood weighting isn’t as accurate as the true posterior distribution, P(z | e) because the sampled variables ignore evidence among z’s non-ancestors

40 Likelihood weighting –Uses all the samples –As evidence variables increase, it becomes harder to keep the weighting constant high and estimate quality drops

41 Gibbs sampling Start with an arbitrary state of the network, with Evidence variables set to their observed values Randomly sample a value for a non evidence variable, conditioned on its: parents, children and childrens parents (Markov blanket) Each state sampled contributes equally to the estimate of the query

42 Some Applications of BN  Medical diagnosis, e.g., lymph-node diseases  Troubleshooting of hardware/software systems  Fraud/uncollectible debt detection  Data mining  Analysis of genetic sequences  Data interpretation, computer vision, image understanding

43 Case study- Pathfinder system Diagnostic system for lymph-node diseases. 60 diseases and 100 symptoms and test-results. 14,000 probabilities Expert consulted to create the net. – 8 hours to determine variables. –35 hours for net topology. –40 hours for probability table values. Apparently, the experts found it quite easy to invent the causal links and probabilities. Pathfinder is now outperforming the world experts in diagnosis. Being extended to several dozen other medical domains.


Download ppt "Bayesian networks Chapter 14. Outline Syntax Semantics."

Similar presentations


Ads by Google