Temporal probability models. Chapter 15, Sections 1 5 1

Similar documents
PROBABILISTIC REASONING OVER TIME

Hidden Markov models 1

Hidden Markov Models. AIMA Chapter 15, Sections 1 5. AIMA Chapter 15, Sections 1 5 1

Temporal probability models. Chapter 15

Dynamic Bayesian Networks and Hidden Markov Models Decision Trees

Temporal probability models. Chapter 15, Sections 1 5 1

Temporal probability models

Course Overview. Summary. Performance of approximation algorithms

Hidden Markov Models (recap BNs)

Kalman Filters, Dynamic Bayesian Networks

Artificial Intelligence

CSCI 360 Introduc/on to Ar/ficial Intelligence Week 2: Problem Solving and Op/miza/on. Professor Wei-Min Shen Week 8.1 and 8.2

Extensions of Bayesian Networks. Outline. Bayesian Network. Reasoning under Uncertainty. Features of Bayesian Networks.

CS 7180: Behavioral Modeling and Decision- making in AI

CS 343: Artificial Intelligence

Hidden Markov Models. Hal Daumé III. Computer Science University of Maryland CS 421: Introduction to Artificial Intelligence 19 Apr 2012

Bayesian Networks BY: MOHAMAD ALSABBAGH

CSEP 573: Artificial Intelligence

Human-Oriented Robotics. Temporal Reasoning. Kai Arras Social Robotics Lab, University of Freiburg

Linear Dynamical Systems

CSE 473: Artificial Intelligence

CS 343: Artificial Intelligence

Markov Models. CS 188: Artificial Intelligence Fall Example. Mini-Forward Algorithm. Stationary Distributions.

Bayesian Methods in Artificial Intelligence

STA 4273H: Statistical Machine Learning

Approximate Inference

Probabilistic Graphical Models

CS532, Winter 2010 Hidden Markov Models

Kalman filtering and friends: Inference in time series models. Herke van Hoof slides mostly by Michael Rubinstein

Bayesian Networks: Construction, Inference, Learning and Causal Interpretation. Volker Tresp Summer 2014

CS 5522: Artificial Intelligence II

CS 5522: Artificial Intelligence II

Announcements. CS 188: Artificial Intelligence Fall VPI Example. VPI Properties. Reasoning over Time. Markov Models. Lecture 19: HMMs 11/4/2008

Hidden Markov Models. Vibhav Gogate The University of Texas at Dallas

1/30/2012. Reasoning with uncertainty III

Hidden Markov Models,99,100! Markov, here I come!

Markov Models and Hidden Markov Models

CS 7180: Behavioral Modeling and Decision- making in AI

PATTERN RECOGNITION AND MACHINE LEARNING CHAPTER 13: SEQUENTIAL DATA

CS 343: Artificial Intelligence

Reasoning Under Uncertainty Over Time. CS 486/686: Introduction to Artificial Intelligence

CS 188: Artificial Intelligence Spring 2009

Lecture 6: Bayesian Inference in SDE Models

CS 5522: Artificial Intelligence II

Introduction to Artificial Intelligence (AI)

Bayesian Networks: Construction, Inference, Learning and Causal Interpretation. Volker Tresp Summer 2016

CS 5522: Artificial Intelligence II

Robert Collins CSE586 CSE 586, Spring 2015 Computer Vision II

Hidden Markov Models. By Parisa Abedi. Slides courtesy: Eric Xing

Introduction to Machine Learning

Announcements. CS 188: Artificial Intelligence Fall Markov Models. Example: Markov Chain. Mini-Forward Algorithm. Example

The Kalman Filter ImPr Talk

CS 188: Artificial Intelligence Spring Announcements

CS 188: Artificial Intelligence Fall Recap: Inference Example

CSE 473: Artificial Intelligence Probability Review à Markov Models. Outline

CS 188: Artificial Intelligence Fall 2011

Hidden Markov Models. Aarti Singh Slides courtesy: Eric Xing. Machine Learning / Nov 8, 2010

Recall: Modeling Time Series. CSE 586, Spring 2015 Computer Vision II. Hidden Markov Model and Kalman Filter. Modeling Time Series

Temporal Models.

Why do we care? Measurements. Handling uncertainty over time: predicting, estimating, recognizing, learning. Dealing with time

Advanced Data Science

Introduction to Machine Learning CMU-10701

Markov Chains and Hidden Markov Models

CS 188: Artificial Intelligence. Our Status in CS188

STA 414/2104: Machine Learning

COMP90051 Statistical Machine Learning

Note Set 5: Hidden Markov Models

9 Forward-backward algorithm, sum-product on factor graphs

Probability, Markov models and HMMs. Vibhav Gogate The University of Texas at Dallas

Probabilistic Graphical Models

CSE 473: Ar+ficial Intelligence. Probability Recap. Markov Models - II. Condi+onal probability. Product rule. Chain rule.

CS188 Outline. We re done with Part I: Search and Planning! Part II: Probabilistic Reasoning. Part III: Machine Learning

Sequential Monte Carlo Methods for Bayesian Computation

Modeling and state estimation Examples State estimation Probabilities Bayes filter Particle filter. Modeling. CSC752 Autonomous Robotic Systems

L06. LINEAR KALMAN FILTERS. NA568 Mobile Robotics: Methods & Algorithms

Our Status in CSE 5522

Template-Based Representations. Sargur Srihari

Markov localization uses an explicit, discrete representation for the probability of all position in the state space.

Linear Dynamical Systems (Kalman filter)

Introduction to Mobile Robotics Probabilistic Robotics

LEARNING DYNAMIC SYSTEMS: MARKOV MODELS

Autonomous Navigation for Flying Robots

Machine Learning 4771

Pattern Recognition and Machine Learning

CS325 Artificial Intelligence Ch. 15,20 Hidden Markov Models and Particle Filtering

Introduction to Artificial Intelligence (AI)

ECE521 Lecture 19 HMM cont. Inference in HMM

Hidden Markov models

CS188 Outline. CS 188: Artificial Intelligence. Today. Inference in Ghostbusters. Probability. We re done with Part I: Search and Planning!

Mathematical Formulation of Our Example

CSE 473: Artificial Intelligence Spring 2014

CS 188: Artificial Intelligence

Why do we care? Examples. Bayes Rule. What room am I in? Handling uncertainty over time: predicting, estimating, recognizing, learning

Chapter 05: Hidden Markov Models

Outline. CSE 573: Artificial Intelligence Autumn Agent. Partial Observability. Markov Decision Process (MDP) 10/31/2012

CS 188: Artificial Intelligence Spring Announcements

Inference in Bayesian networks

Bayesian Machine Learning - Lecture 7

Bayesian Approaches Data Mining Selected Technique

Bayes Filter Reminder. Kalman Filter Localization. Properties of Gaussians. Gaussians. Prediction. Correction. σ 2. Univariate. 1 2πσ e.

Transcription:

Temporal probability models Chapter 15, Sections 1 5 Chapter 15, Sections 1 5 1

Outline Time and uncertainty Inference: filtering, prediction, smoothing Hidden Markov models Kalman filters (a brief mention) Dynamic Bayesian networks Particle filtering Chapter 15, Sections 1 5 2

Time and uncertainty The world changes; we need to track and predict it Diabetes management vs vehicle diagnosis Basic idea: copy state and evidence variables for each time step Xt = set of unobservable state variables at time t e.g., BloodSugart, StomachContentst, etc. Et = set of observable evidence variables at time t e.g., M easuredbloodsugart, P ulseratet, F oodeatent This assumes discrete time; step size depends on problem Notation: Xa:b = Xa, Xa+1,..., Xb 1, Xb Chapter 15, Sections 1 5 3

Markov processes (Markov chains) Construct a Bayes net from these variables: parents? Markov assumption: Xt depends on bounded subset of X0:t 1 First-order Markov process: P(Xt X0:t 1) = P(Xt Xt 1) Second-order Markov process: P(Xt X0:t 1) = P(Xt Xt 2, Xt 1) First order X t 2 X t 1 X t X t +1 X t +2 Second order X t 2 X t 1 X t X t +1 X t +2 Sensor Markov assumption: P(Et X0:t, E0:t 1) = P(Et Xt) Stationary process: transition model P(Xt Xt 1) and sensor model P(Et Xt) fixed for all t Chapter 15, Sections 1 5 4

Example Rain t 1 R t 1 t P(R ) t f 0.7 0.3 Rain t Rain t +1 R t P(U t ) t 0.9 f 0.2 Umbrella t 1 Umbrella t Umbrella t +1 First-order Markov assumption not exactly true in real world! Possible fixes: 1. Increase order of Markov process 2. Augment state, e.g., add T empt, P ressuret Example: robot motion. Augment position and velocity with Batteryt Chapter 15, Sections 1 5 5

Inference tasks Filtering: P(Xt e1:t) belief state input to the decision process of a rational agent Prediction: P(Xt+k e1:t) for k > 0 evaluation of possible action sequences; like filtering without the evidence Smoothing: P(Xk e1:t) for 0 k < t better estimate of past states, essential for learning Most likely explanation: arg maxx1:t P (x 1:t e1:t) speech recognition, decoding with a noisy channel Chapter 15, Sections 1 5 6

Filtering Aim: devise a recursive state estimation algorithm: P(Xt+1 e1:t+1) = f(et+1, P(Xt e1:t)) P(Xt+1 e1:t+1) = P(Xt+1 e1:t, et+1) = αp(et+1 Xt+1, e1:t)p(xt+1 e1:t) = αp(et+1 Xt+1)P(Xt+1 e1:t) I.e., prediction + estimation. Prediction by summing out Xt: P(Xt+1 e1:t+1) = αp(et+1 Xt+1)Σxt P(X t+1 xt, e1:t)p (xt e1:t) = αp(et+1 Xt+1)Σxt P(X t+1 xt)p (xt e1:t) f1:t+1 = Forward(f1:t, et+1) where f1:t = P(Xt e1:t) Time and space constant (independent of t) Chapter 15, Sections 1 5 7

True False 0.500 0.500 Rain 0 Filtering example 0.500 0.500 0.818 0.182 Rain 1 Umbrella 1 0.627 0.373 0.883 0.117 Rain 2 Umbrella 2 Chapter 15, Sections 1 5 8

Smoothing X 0 X 1 X k X t E 1 E k E t Divide evidence e1:t into e1:k, ek+1:t: P(Xk e1:t) = P(Xk e1:k, ek+1:t) = αp(xk e1:k)p(ek+1:t Xk, e1:k) = αp(xk e1:k)p(ek+1:t Xk) = αf1:kbk+1:t Backward message computed by a backwards recursion: P(ek+1:t Xk) = Σx k+1 P(ek+1:t Xk, xk+1)p(xk+1 Xk) = Σx k+1 P (ek+1:t xk+1)p(xk+1 Xk) = Σx k+1 P (ek+1 xk+1)p (ek+2:t xk+1)p(xk+1 Xk) Chapter 15, Sections 1 5 9

Smoothing example 0.500 0.500 0.627 0.373 True False 0.500 0.500 0.818 0.182 0.883 0.117 forward 0.883 0.117 0.883 0.117 smoothed 0.690 0.410 1.000 1.000 backward Rain 0 Rain 1 Rain 2 Umbrella 1 Umbrella 2 Forward backward algorithm: cache forward messages along the way Time linear in t (polytree inference), space O(t f ) Chapter 15, Sections 1 5 10

Most likely explanation Most likely sequence sequence of most likely states!!!! Most likely path to each xt+1 = most likely path to some xt plus one more step max P(x 1,..., xt, Xt+1 e1:t+1) x1...xt = P(et+1 Xt+1) max xt Identical to filtering, except f1:t replaced by P(Xt+1 xt) max P (x1,..., xt 1, xt e1:t) x1...xt 1 m1:t = max x1...xt 1 P(x 1,..., xt 1, Xt e1:t), I.e., m1:t(i) gives the probability of the most likely path to state i. Update has sum replaced by max, giving the Viterbi algorithm: m1:t+1 = P(et+1 Xt+1) max (P(Xt+1 xt)m1:t) xt Chapter 15, Sections 1 5 11

Viterbi example Rain 1 Rain 2 Rain 3 Rain 4 Rain 5 state space paths true false true false true false true false true false umbrella true true false true true most likely paths.8182.5155.0361.0334.0210.1818.0491.1237.0173.0024 m 1:2 m 1:3 m 1:4 m 1:1 m 1:5 Chapter 15, Sections 1 5 12

Hidden Markov models Xt is a single, discrete variable (usually Et is too) Domain of Xt is {1,..., S} Transition matrix Tij = P (Xt = j Xt 1 = i), e.g., 0.7 0.3 0.3 0.7 Sensor matrix Ot for each time step, diagonal elements P (et Xt = i) e.g., with U1 = true, O1 = 0.9 0 0 0.2 Forward and backward messages as column vectors: f1:t+1 = αot+1t f1:t bk+1:t = TOk+1bk+2:t Forward-backward algorithm needs time O(S 2 t) and space O(St) Chapter 15, Sections 1 5 13

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 14

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 15

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 16

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 17

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 18

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 19

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 20

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 21

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 22

Country dance algorithm Can avoid storing all forward messages in smoothing by running forward algorithm backwards: f1:t+1 = αot+1t f1:t O 1 t+1f1:t+1 = αt f1:t α (T ) 1 O 1 t+1f1:t+1 = f1:t Algorithm: forward pass computes ft, backward pass does fi, bi Chapter 15, Sections 1 5 23

Kalman filters Modelling systems described by a set of continuous variables, e.g., tracking a bird flying Xt = X, Y, Z, Ẋ, Ẏ, Ż. Airplanes, robots, ecosystems, economies, chemical plants, planets,... X t X t+1 X t X t+1 Z t Z t+1 Gaussian prior, linear Gaussian transition model and sensor model Chapter 15, Sections 1 5 24

Updating Gaussian distributions Prediction step: if P(Xt e1:t) is Gaussian, then prediction P(Xt+1 e1:t) = xt P(X t+1 xt)p (xt e1:t) dxt is Gaussian. If P(Xt+1 e1:t) is Gaussian, then the updated distribution P(Xt+1 e1:t+1) = αp(et+1 Xt+1)P(Xt+1 e1:t) is Gaussian Hence P(Xt e1:t) is multivariate Gaussian N(µ t, Σt) for all t General (nonlinear, non-gaussian) process: description of posterior grows unboundedly as t Chapter 15, Sections 1 5 25

Chapter 15, Sections 1 5 26 0 z1 * -8-6 -4-2 0 2 4 6 8 X position 0.05 0.1 P(x1) 0.15 P(X) 0.25 P(x0) 0.2 0.3 P(x1 z1=2.5) 0.35 0.4 0.45 µt+1 = (σ2 t + σ 2 x)zt+1 + σ 2 zµt σ 2 t + σ 2 x + σ 2 z σ 2 t+1 = (σ2 t + σ 2 x)σ 2 z σ 2 t + σ 2 x + σ 2 z Gaussian random walk on X axis, s.d. σx, sensor s.d. σz Simple 1-D example

General Kalman update Transition and sensor models: P (xt+1 xt) = N(Fxt, Σx)(xt+1) P (zt xt) = N(Hxt, Σz)(zt) F is the matrix for the transition; Σx the transition noise covariance H is the matrix for the sensors; Σz the sensor noise covariance Filter computes the following update: µt+1 = Fµ t + Kt+1(zt+1 HFµ t ) Σt+1 = (I Kt+1)(FΣtF + Σx) where Kt+1 = (FΣtF + Σx)H (H(FΣtF + Σx)H + Σz) 1 is the Kalman gain matrix Σt and Kt are independent of observation sequence, so compute offline Chapter 15, Sections 1 5 27

2-D tracking example: filtering 12 11 10 9 8 7 6 8 10 12 14 16 18 20 22 24 26 X Y 2D filtering true observed filtered Chapter 15, Sections 1 5 28

2-D tracking example: smoothing 12 11 10 9 8 7 6 8 10 12 14 16 18 20 22 24 26 X Y 2D smoothing true observed smoothed Chapter 15, Sections 1 5 29

Where it breaks Cannot be applied if the transition model is nonlinear Extended Kalman Filter models transition as locally linear around xt = µ t Fails if systems is locally unsmooth Chapter 15, Sections 1 5 30

Dynamic Bayesian networks Xt, Et contain arbitrarily many variables in a replicated Bayes net BMeter 1 P(R 0 ) 0.7 R 0 t f P(R 1 ) 0.7 0.3 Rain 0 Rain 1 Battery 0 Battery 1 R 1 t f Umbrella 1 P(U 1 ) 0.9 0.2 X 0 txx 0 X 1 X 1 Z1 Chapter 15, Sections 1 5 31

DBNs vs. HMMs Every HMM is a single-variable DBN; every discrete DBN is an HMM X t X t+1 Y t Y t+1 Z t Z t+1 Sparse dependencies exponentially fewer parameters; e.g., 20 state variables, three parents each DBN has 20 2 3 = 160 parameters, HMM has 2 20 2 20 10 12 Chapter 15, Sections 1 5 32

Chapter 15, Sections 1 5 33 txx 0 X 0 X 1 X 1 Z1 3 2 1 0-1 15 20 25 30 Time step P(BMBroken...5555005555...) P(BMBroken...5555000000...) E(Battery) Battery 0 Battery 1 5 4 E(Battery...5555005555...) E(Battery...5555000000...) BMeter 1 BMBroken 0 BMBroken 1 E.g., where are bin Laden and my keys? What s the battery charge? Every Kalman filter model is a DBN, but few DBNs are KFs; real world requires non-gaussian posteriors DBNs vs Kalman filters

t f t f 0 t f t f t f t f t f t f t f t f t f t f t f t f t f t f Exact inference in DBNs Naive method: unroll the network and run any exact algorithm P(R R 0 P(R 1 ) 0 ) P(R ) R 0 P(R 1 ) 0.7 0.7 0.7 0.7 0.3 0.3 Rain 0 Rain 1 Rain 0 Rain 1 R 0 P(R 1 ) 0.7 0.3 Rain 2 R 0 P(R 1 ) 0.7 0.3 Rain 3 R 0 P(R 1 ) 0.7 0.3 Rain 4 R 0 P(R 1 ) 0.7 0.3 Rain 5 R 0 P(R 1 ) 0.7 0.3 Rain 6 R 0 P(R 1 ) 0.7 0.3 Rain 7 R 1 P(U 1 ) 0.9 0.2 R 1 P(U 1 ) 0.9 0.2 R 1 P(U 1 ) 0.9 0.2 R 1 P(U 1 ) 0.9 0.2 R 1 P(U 1 ) 0.9 0.2 R 1 P(U 1 ) 0.9 0.2 R 1 P(U 1 ) 0.9 0.2 R 1 P(U 1 ) 0.9 0.2 Umbrella 1 Umbrella 1 Umbrella 2 Umbrella 3 Umbrella 4 Umbrella 5 Umbrella 6 Umbrella 7 Problem: inference cost for each update grows with t Rollup filtering: add slice t + 1, sum out slice t using variable elimination Largest factor is O(d n+1 ), update cost O(d n+2 ) (cf. HMM update cost O(d 2n )) Chapter 15, Sections 1 5 34

Chapter 15, Sections 1 5 35 0 0 5 10 15 20 25 30 35 40 45 50 Time step 0.2 RMS error 0.4 0.6 0.8 LW(10) LW(100) LW(1000) LW(10000) 1 LW samples pay no attention to the evidence! fraction agreeing falls exponentially with t number of samples required grows exponentially with t Umbrella 1 Umbrella 2 Umbrella 3 Umbrella 4 Umbrella 5 Rain 0 Rain 1 Rain 2 Rain 3 Rain 4 Rain 5 Set of weighted samples approximates the belief state Likelihood weighting for DBNs

Particle filtering Basic idea: ensure that the population of samples ( particles ) tracks the high-likelihood regions of the state-space Replicate particles proportional to likelihood for et Rain t Rain t +1 Rain t +1 Rain t +1 true false (a) Propagate (b) Weight (c) Resample Widely used for tracking nonlinear systems, esp. in vision Also used for simultaneous localization and mapping in mobile robots 10 5 -dimensional state space Chapter 15, Sections 1 5 36

Particle filtering contd. Assume consistent at time t: N(xt e1:t)/n = P (xt e1:t) Propagate forward: populations of xt+1 are N(xt+1 e1:t) = Σxt P (x t+1 xt)n(xt e1:t) Weight samples by their likelihood for et+1: W (xt+1 e1:t+1) = P (et+1 xt+1)n(xt+1 e1:t) Resample to obtain populations proportional to W : N(xt+1 e1:t+1)/n = αw (xt+1 e1:t+1) = αp (et+1 xt+1)n(xt+1 e1:t) = αp (et+1 xt+1)σxt P (x t+1 xt)n(xt e1:t) = α P (et+1 xt+1)σxt P (x t+1 xt)p (xt e1:t) = P (xt+1 e1:t+1) Chapter 15, Sections 1 5 37

Chapter 15, Sections 1 5 38 0 0 5 10 15 20 25 30 35 40 45 50 Time step 0.2 Avg absolute error 0.4 0.6 0.8 LW(25) LW(100) LW(1000) LW(10000) ER/SOF(25) 1 Approximation error of particle filtering remains bounded over time, at least empirically theoretical analysis is difficult Particle filtering performance

Summary Temporal models use state and sensor variables replicated over time Markov assumptions and stationarity assumption, so we need transition modelp(xt Xt 1) sensor model P(Et Xt) Tasks are filtering, prediction, smoothing, most likely sequence; all done recursively with constant cost per time step Hidden Markov models have a single discrete state variable; used for speech recognition Kalman filters allow n state variables, linear Gaussian, O(n 3 ) update Dynamic Bayes nets subsume HMMs, Kalman filters; exact update intractable Particle filtering is a good approximate filtering algorithm for DBNs Chapter 15, Sections 1 5 39