CS 416 Artificial Intelligence Lecture 15 Uncertainty Chapter 14 Lecture 15 Uncertainty Chapter 14.

Slides:



Advertisements
Similar presentations
CPSC 422, Lecture 11Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 11 Jan, 29, 2014.
Advertisements

Probabilistic models Jouni Tuomisto THL. Outline Deterministic models with probabilistic parameters Hierarchical Bayesian models Bayesian belief nets.
Lirong Xia Hidden Markov Models Tue, March 28, 2014.
Lirong Xia Approximate inference: Particle filter Tue, April 1, 2014.
Homework 3: Naive Bayes Classification
Probabilistic Reasoning (2)
Markov Networks.
Exact Inference (Last Class) variable elimination  polytrees (directed graph with at most one undirected path between any two vertices; subset of DAGs)
Inference in Bayesian Nets
CS 188: Artificial Intelligence Fall 2009 Lecture 20: Particle Filtering 11/5/2009 Dan Klein – UC Berkeley TexPoint fonts used in EMF. Read the TexPoint.
. PGM: Tirgul 8 Markov Chains. Stochastic Sampling  In previous class, we examined methods that use independent samples to estimate P(X = x |e ) Problem:
Bayesian Networks. Graphical Models Bayesian networks Conditional random fields etc.
Course overview Tuesday lecture –Those not presenting turn in short review of a paper using the method being discussed Thursday computer lab –Turn in short.
Representing Uncertainty CSE 473. © Daniel S. Weld 2 Many Techniques Developed Fuzzy Logic Certainty Factors Non-monotonic logic Probability Only one.
5/25/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 16, 6/1/2005 University of Washington, Department of Electrical Engineering Spring 2005.
CS 188: Artificial Intelligence Spring 2007 Lecture 14: Bayes Nets III 3/1/2007 Srini Narayanan – ICSI and UC Berkeley.
CS 188: Artificial Intelligence Fall 2006 Lecture 17: Bayes Nets III 10/26/2006 Dan Klein – UC Berkeley.
10/22  Homework 3 returned; solutions posted  Homework 4 socket opened  Project 3 assigned  Mid-term on Wednesday  (Optional) Review session Tuesday.
Announcements Homework 8 is out Final Contest (Optional)
1 Bayesian Networks Chapter ; 14.4 CS 63 Adapted from slides by Tim Finin and Marie desJardins. Some material borrowed from Lise Getoor.
Bayesian Networks Textbook: Probabilistic Reasoning, Sections 1-2, pp
Approximate Inference 2: Monte Carlo Markov Chain
Bayesian networks Chapter 14. Outline Syntax Semantics.
Topics on Final Perceptrons SVMs Precision/Recall/ROC Decision Trees Naive Bayes Bayesian networks Adaboost Genetic algorithms Q learning Not on the final:
Recap: Reasoning Over Time  Stationary Markov models  Hidden Markov models X2X2 X1X1 X3X3 X4X4 rainsun X5X5 X2X2 E1E1 X1X1 X3X3 X4X4 E2E2 E3E3.
INC 551 Artificial Intelligence Lecture 8 Models of Uncertainty.
CSC321: 2011 Introduction to Neural Networks and Machine Learning Lecture 11: Bayesian learning continued Geoffrey Hinton.
CS 188: Artificial Intelligence Fall 2006 Lecture 18: Decision Diagrams 10/31/2006 Dan Klein – UC Berkeley.
Bayesian approaches to knowledge representation and reasoning Part 1 (Chapter 13)
UBC Department of Computer Science Undergraduate Events More
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
Bayes’ Nets: Sampling [These slides were created by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley. All CS188 materials are available.
1 CMSC 671 Fall 2001 Class #21 – Tuesday, November 13.
Exact Inference (Last Class) Variable elimination  polytrees (directed graph with at most one undirected path between any two vertices; subset of DAGs)
The famous “sprinkler” example (J. Pearl, Probabilistic Reasoning in Intelligent Systems, 1988)
CPSC 422, Lecture 11Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 11 Oct, 2, 2015.
QUIZ!!  In HMMs...  T/F:... the emissions are hidden. FALSE  T/F:... observations are independent given no evidence. FALSE  T/F:... each variable X.
An Introduction to Markov Chain Monte Carlo Teg Grenager July 1, 2004.
Probabilistic models Jouni Tuomisto THL. Outline Deterministic models with probabilistic parameters Hierarchical Bayesian models Bayesian belief nets.
Bayesian networks and their application in circuit reliability estimation Erin Taylor.
CS 188: Artificial Intelligence Bayes Nets: Approximate Inference Instructor: Stuart Russell--- University of California, Berkeley.
Inference Algorithms for Bayes Networks
Quick Warm-Up Suppose we have a biased coin that comes up heads with some unknown probability p; how can we use it to produce random bits with probabilities.
Probabilistic Reasoning Inference and Relational Bayesian Networks.
QUIZ!!  T/F: You can always (theoretically) do BNs inference by enumeration. TRUE  T/F: In VE, always first marginalize, then join. FALSE  T/F: VE is.
Web-Mining Agents Data Mining Prof. Dr. Ralf Möller Universität zu Lübeck Institut für Informationssysteme Karsten Martiny (Übungen)
CS 541: Artificial Intelligence Lecture VII: Inference in Bayesian Networks.
CS 416 Artificial Intelligence Lecture 16 Uncertainty Chapter 14 Lecture 16 Uncertainty Chapter 14.
CS498-EA Reasoning in AI Lecture #19 Professor: Eyal Amir Fall Semester 2011.
CS 541: Artificial Intelligence
Web-Mining Agents Data Mining
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 12
CS b553: Algorithms for Optimization and Learning
Artificial Intelligence
CS 4/527: Artificial Intelligence
CAP 5636 – Advanced Artificial Intelligence
Markov Networks.
Advanced Artificial Intelligence
Inference Inference: calculating some useful quantity from a joint probability distribution Examples: Posterior probability: Most likely explanation: B.
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 12
Instructors: Fei Fang (This Lecture) and Dave Touretzky
CS 188: Artificial Intelligence
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 11
Class #19 – Tuesday, November 3
CS 188: Artificial Intelligence Fall 2008
Class #16 – Tuesday, October 26
CS 188: Artificial Intelligence Fall 2007
Quick Warm-Up Suppose we have a biased coin that comes up heads with some unknown probability p; how can we use it to produce random bits with probabilities.
Markov Networks.
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 12
Presentation transcript:

CS 416 Artificial Intelligence Lecture 15 Uncertainty Chapter 14 Lecture 15 Uncertainty Chapter 14

Late start on Thursday CS Annual Feedback Forum Thursday, March 23, 4:30 – 5:25 MEC 205 Pizza AI class will start at 5:30 on Thursday CS Annual Feedback Forum Thursday, March 23, 4:30 – 5:25 MEC 205 Pizza AI class will start at 5:30 on Thursday

Conditional probability The probability of a given all we know is b P (a | b)P (a | b) Written as an unconditional probability The probability of a given all we know is b P (a | b)P (a | b) Written as an unconditional probability

A distribution over Y can be obtained by summing out all the other variables from any joint distribution containing Y We need the full joint distribution to sum this up A distribution over Y can be obtained by summing out all the other variables from any joint distribution containing Y We need the full joint distribution to sum this up Conditioning eventevidence all other variables anywhere x and e are true

Bayes Network Bayes Network captures the full joint distribution For comparison: Bayes Network captures the full joint distribution For comparison:

Example P(B | john calls, mary calls)

Example P(B | john calls, mary calls) old way

Example Depth- first tree traversal required required

Example O(2 n ) time complexity Wasted repeated computations

Example Complexity of Bayes Net Bayes Net reduces space complexity of full-joint distributionBayes Net reduces space complexity of full-joint distribution Bayes Net does not reduce time complexity for general caseBayes Net does not reduce time complexity for general case Complexity of Bayes Net Bayes Net reduces space complexity of full-joint distributionBayes Net reduces space complexity of full-joint distribution Bayes Net does not reduce time complexity for general caseBayes Net does not reduce time complexity for general case

Time complexity Note repeated subexpressions Dynamic Programming Note repeated subexpressions Dynamic Programming

Fibonacci sequence example function fib(n) if n = 0 or n = 1 return n else return fib(n − 1) + fib(n − 2) 1. 1.fib(5) 2. 2.fib(4) + fib(3) 3. 3.(fib(3) + fib(2)) + (fib(2) + fib(1)) 4. 4.((fib(2) + fib(1)) + (fib(1) + fib(0))) + ((fib(1) + fib(0)) + fib(1)) 5. 5.(((fib(1) + fib(0)) + fib(1)) + (fib(1) + fib(0))) + ((fib(1) + fib(0)) + fib(1)) Fibonacci sequence example function fib(n) if n = 0 or n = 1 return n else return fib(n − 1) + fib(n − 2) 1. 1.fib(5) 2. 2.fib(4) + fib(3) 3. 3.(fib(3) + fib(2)) + (fib(2) + fib(1)) 4. 4.((fib(2) + fib(1)) + (fib(1) + fib(0))) + ((fib(1) + fib(0)) + fib(1)) 5. 5.(((fib(1) + fib(0)) + fib(1)) + (fib(1) + fib(0))) + ((fib(1) + fib(0)) + fib(1))

Dynamic Programming Memoization var m := map(int, int) function fib(n) if n not in keys(m) m[n] := fib(n − 1) + fib(n − 2) return m[n]Memoization var m := map(int, int) function fib(n) if n not in keys(m) m[n] := fib(n − 1) + fib(n − 2) return m[n]

Approximate Inference It’s expensive to work with the full joint distrbution… whether as a table or as a Bayesian Network Is approximation good enough? Monte Carlo It’s expensive to work with the full joint distrbution… whether as a table or as a Bayesian Network Is approximation good enough? Monte Carlo

Use samples to approximate posterior probs. Simulated annealing used Monte Carlo theories to justify why random guesses and sometimes going uphill can lead to optimalitySimulated 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?How many are needed? Where should you take the samples?Where should you take the samples? Use samples to approximate posterior probs. Simulated annealing used Monte Carlo theories to justify why random guesses and sometimes going uphill can lead to optimalitySimulated 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?How many are needed? Where should you take the samples?Where should you take the samples?

An example P(WetGrass) Requires full-joint dist.Requires full-joint dist. Full-joint is O(2 n )Full-joint is O(2 n ) Even unlikely events are tabulated in full-jointEven unlikely events are tabulated in full-jointP(WetGrass) Requires full-joint dist.Requires full-joint dist. Full-joint is O(2 n )Full-joint is O(2 n ) Even unlikely events are tabulated in full-jointEven unlikely events are tabulated in full-joint

Prior sampling An ability to model the prior probabilities of a set of random variables Imagine generating 100 of these samples An ability to model the prior probabilities of a set of random variables Imagine generating 100 of these samples

Prior sampling Define S PS (x 1, x 2, …, x n ) Probability that event (x 1, x 2, …, x n ) is generated by networkProbability that event (x 1, x 2, …, x n ) is generated by network Define S PS (x 1, x 2, …, x n ) Probability that event (x 1, x 2, …, x n ) is generated by networkProbability that event (x 1, x 2, …, x n ) is generated by network

Approximating true distribution With enough samples, perfect modeling is possible

Rejection sampling Compute P(X | e) Use PriorSample (S PS ) and create N samplesUse PriorSample (S PS ) and create N samples Inspect each sample for TRUTH of eInspect each sample for TRUTH of e Of those samples consistent with e, tabulate P(X|e)Of those samples consistent with e, tabulate P(X|e) –Keep track of X values –Normalize for total number of samples Compute P(X | e) Use PriorSample (S PS ) and create N samplesUse PriorSample (S PS ) and create N samples Inspect each sample for TRUTH of eInspect each sample for TRUTH of e Of those samples consistent with e, tabulate P(X|e)Of those samples consistent with e, tabulate P(X|e) –Keep track of X values –Normalize for total number of samples

Example P(Rain | Sprinkler = true)P(Rain | Sprinkler = true) Use Bayes Net to generate 100 samplesUse 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) = Normalize ( ) = P(Rain | Sprinkler=true) = Normalize ( ) = P(Rain | Sprinkler = true)P(Rain | Sprinkler = true) Use Bayes Net to generate 100 samplesUse 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) = Normalize ( ) = P(Rain | Sprinkler=true) = Normalize ( ) =

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 evidenceStandard 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 smallAs problems become complex, number of samples consistent with evidence becomes small Standard deviation of the error in probability is proportional to 1/sqrt(n), where n is the number of samples consistent with evidenceStandard 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 smallAs problems become complex, number of samples consistent with evidence becomes small

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

Example – likelihood weighting P (Rain | Sprinkler=true, WetGrass=true)

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

Example – likelihood weighting Keep track: (T, T, T, T) with weight 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 variablesSo final probability is a function of what comes from sampling the free variables while constraining the evidence variables Keep track: (T, T, T, T) with weight 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 variablesSo final probability is a function of what comes from sampling the free variables while constraining the evidence variables

Comparing techniques Likelihood uses all samplesLikelihood uses all samples –More efficient than rejection sampling Less effective if lots of evidence variables (small weights)Less effective if lots of evidence variables (small weights) Less effective if evidence is late in variable ordering (samples generated w/o early influence of evidence)Less effective if evidence is late in variable ordering (samples generated w/o early influence of evidence) Likelihood uses all samplesLikelihood uses all samples –More efficient than rejection sampling Less effective if lots of evidence variables (small weights)Less effective if lots of evidence variables (small weights) Less effective if evidence is late in variable ordering (samples generated w/o early influence of evidence)Less effective if evidence is late in variable ordering (samples generated w/o early influence of evidence)

Markov Chain Monte Carlo (MCMC) Imagine being in a current stateImagine being in a current state –An assignment to all the random variables The next state is selected according to random sample of one of the nonevidence variables, X iThe next state is selected according to random sample of one of the nonevidence variables, X i –Conditioned on the current values of the variables in the current state MCMC wanders around state space, flipping one variable at a time while keeping evidence variables fixedMCMC wanders around state space, flipping one variable at a time while keeping evidence variables fixed Imagine being in a current stateImagine being in a current state –An assignment to all the random variables The next state is selected according to random sample of one of the nonevidence variables, X iThe next state is selected according to random sample of one of the nonevidence variables, X i –Conditioned on the current values of the variables in the current state MCMC wanders around state space, flipping one variable at a time while keeping evidence variables fixedMCMC wanders around state space, flipping one variable at a time while keeping evidence variables fixed

Example - MCMC Solve P(Rain | Sprinkler=TRUE, WetGrass = TRUE) Fix Sprinkler and WetGrass to TRUEFix Sprinkler and WetGrass to TRUE Initialize “state” to [T Cloudy, T Sprinkler, F Rain, T WetGrass ]Initialize “state” to [T Cloudy, T Sprinkler, F Rain, T WetGrass ] Sample Cloudy, P(Cloudy | T Sprinkler, F Rain )Sample Cloudy, P(Cloudy | T Sprinkler, F Rain ) –We want to “flip the cloudy bit” subject to conditional probabilities of its parents, children, and childrens’ parents (Markov blanket) –Cloudy becomes False Solve P(Rain | Sprinkler=TRUE, WetGrass = TRUE) Fix Sprinkler and WetGrass to TRUEFix Sprinkler and WetGrass to TRUE Initialize “state” to [T Cloudy, T Sprinkler, F Rain, T WetGrass ]Initialize “state” to [T Cloudy, T Sprinkler, F Rain, T WetGrass ] Sample Cloudy, P(Cloudy | T Sprinkler, F Rain )Sample Cloudy, P(Cloudy | T Sprinkler, F Rain ) –We want to “flip the cloudy bit” subject to conditional probabilities of its parents, children, and childrens’ parents (Markov blanket) –Cloudy becomes False

Example - MCMC Solve P(Rain | Sprinkler=TRUE, WetGrass = TRUE) Fix Sprinkler and WetGrass to TRUEFix Sprinkler and WetGrass to TRUE “state” is [F Cloudy, T Sprinkler, F Rain, T WetGrass ]“state” is [F Cloudy, T Sprinkler, F Rain, T WetGrass ] Sample P(Rain | F Cloudy, T Sprinkler, T WetGrass )Sample P(Rain | F Cloudy, T Sprinkler, T WetGrass ) –Rain becomes TRUE “state” is [F Cloudy, T Sprinkler, T Rain, T WetGrass ]“state” is [F Cloudy, T Sprinkler, T Rain, T WetGrass ] Solve P(Rain | Sprinkler=TRUE, WetGrass = TRUE) Fix Sprinkler and WetGrass to TRUEFix Sprinkler and WetGrass to TRUE “state” is [F Cloudy, T Sprinkler, F Rain, T WetGrass ]“state” is [F Cloudy, T Sprinkler, F Rain, T WetGrass ] Sample P(Rain | F Cloudy, T Sprinkler, T WetGrass )Sample P(Rain | F Cloudy, T Sprinkler, T WetGrass ) –Rain becomes TRUE “state” is [F Cloudy, T Sprinkler, T Rain, T WetGrass ]“state” is [F Cloudy, T Sprinkler, T Rain, T WetGrass ]

Nice method of operation The sampling process settles into a “dynamic equilibrium” in which the long-run fraction of time spent in each state is exactly proportional to its posterior probabilityThe sampling process settles into a “dynamic equilibrium” in which the long-run fraction of time spent in each state is exactly proportional to its posterior probability Let q(x  x’) = probability of transitioning from state x to x’Let q(x  x’) = probability of transitioning from state x to x’ A Markov chain is a sequence of state transitions according to q( ) functionsA Markov chain is a sequence of state transitions according to q( ) functions  t (x) measures the probability of being in state x after t steps The sampling process settles into a “dynamic equilibrium” in which the long-run fraction of time spent in each state is exactly proportional to its posterior probabilityThe sampling process settles into a “dynamic equilibrium” in which the long-run fraction of time spent in each state is exactly proportional to its posterior probability Let q(x  x’) = probability of transitioning from state x to x’Let q(x  x’) = probability of transitioning from state x to x’ A Markov chain is a sequence of state transitions according to q( ) functionsA Markov chain is a sequence of state transitions according to q( ) functions  t (x) measures the probability of being in state x after t steps

Markov chains  t+1 (x’) = probability of being in x’ after t+1 steps If  t =  t+1 we have reached a stationary distributionIf  t =  t+1 we have reached a stationary distribution  t+1 (x’) = probability of being in x’ after t+1 steps If  t =  t+1 we have reached a stationary distributionIf  t =  t+1 we have reached a stationary distribution