6PP

Announcements
CS 188: Artificial Intelligence
Fall 2006
Lecture 19: Hidden Markov Models
11/02/2006
ƒ Optional midterm
ƒ On Tuesday 11/21 in class
ƒ We will count the midterms and final as 1 / 1 / 2, and
drop the lowest (or halve the final weight)
ƒ Will also run grades as if this midterm did not happen
ƒ You will get the better of the two grades
ƒ Projects
ƒ 3.2 up, do written questions before programming
Dan Klein – UC Berkeley
Recap: Value of Information
ƒ
Current evidence E=e, utility depends on S=s
ƒ
Potential new evidence E’: suppose we knew E’ = e’
ƒ
BUT E’ is a random variable whose value is currently unknown, so:
VPI Scenarios
ƒ Imagine actions 1 and 2, for which U1 > U2
ƒ How much will information about Ej be worth?
ƒ Must compute expected gain over all possible values
ƒ
(VPI = value of perfect information)
Reasoning over Time
ƒ Often, we want to reason about a sequence of
observations
ƒ
ƒ
ƒ
ƒ
Speech recognition
Robot localization
User attention
Medical monitoring
ƒ Need to introduce time into our models
ƒ Basic approach: hidden Markov models (HMMs)
ƒ More general: dynamic Bayes’ nets
Little – we’re sure
action 1 is better.
A lot – either could
be much better
Little – info likely to
change our action
but not our utility
Markov Models
ƒ A Markov model is a chain
- structured BN
ƒ Each node is identically distributed (stationarity)
ƒ Value of X at a given time is called the state
ƒ As a BN:
X1
X2
X3
X4
ƒ Parameters: called transition probabilities or
dynamics, specify how the state evolves over time
(also, initial probs)
1
Conditional Independence
Example: Markov Chain
0.1
ƒ Weather:
X1
X2
X3
X4
ƒ States: X = {rain, sun}
ƒ Transitions:
ƒ Basic conditional independence:
ƒ Past and future independent of the present
ƒ Each time step only depends on the previous
ƒ This is called the (first order) Markov property
0.9
rain
sun
This is a
CPT, not a
BN!
0.9
0.1
ƒ Initial distribution: 1.0 sun
ƒ What’s the probability distribution after one step?
ƒ Note that the chain is just a (growing BN)
ƒ We can always use generic BN reasoning on it (if we
truncate the chain)
Mini-Forward Algorithm
ƒ Question: probability of being in state x at time t?
ƒ Slow answer:
ƒ Enumerate all sequences of length t which end in s
ƒ Add up their probabilities
Mini-Forward Algorithm
ƒ Better way: cached incremental belief updates
sun
sun
sun
sun
rain
rain
rain
rain
…
Forward simulation
Example
Stationary Distributions
ƒ If we simulate the chain long enough:
ƒ From initial observation of sun
ƒ What happens?
ƒ Uncertainty accumulates
ƒ Eventually, we have no idea what the state is!
P(X1)
P(X2)
P(X3)
P(X∞)
ƒ From initial observation of rain
P(X1)
P(X2)
P(X3)
ƒ Stationary distributions:
ƒ For most chains, the distribution we end up in is
independent of the initial distribution
ƒ Called the stationary distribution of the chain
ƒ Usually, can only predict a short time out
P(X∞)
2
Web Link Analysis
ƒ PageRank over a web graph
Most Likely Explanation
ƒ Question: most likely sequence ending in x at t?
ƒ Each web page is a state
ƒ Initial distribution: uniform over pages
ƒ Transitions:
ƒ E.g. if sun on day 4, what’s the most likely sequence?
ƒ Intuitively: probably sun all four days
ƒ With prob. c, uniform jump to a
random page (dotted lines)
ƒ With prob. 1-c, follow a random
outlink (solid lines)
ƒ Slow answer: enumerate and score
ƒ Stationary distribution
ƒ
ƒ
ƒ
ƒ
…
Will spend more time on highly reachable pages
E.g. many ways to get to the Acrobat Reader download page!
Somewhat robust to link spam
Google 1.0 returned the set of pages containing all your
keywords in decreasing rank, now all search engines use link
analysis along with many other factors
Mini-Viterbi Algorithm
ƒ Better answer: cached incremental updates
sun
sun
sun
sun
rain
rain
rain
rain
Mini-Viterbi
sun
sun
sun
sun
rain
rain
rain
rain
ƒ Define:
ƒ Read best sequence off of m and a vectors
Example
Example
3
Example
Example
Hidden Markov Models
Example
ƒ Markov chains not so useful for most agents
ƒ Eventually you don’t know anything anymore
ƒ Need observations to update your beliefs
ƒ Hidden Markov models (HMMs)
ƒ Underlying Markov chain over states S
ƒ You observe outputs (effects) at each time step
ƒ As a Bayes’ net:
X1
E1
X2
E2
X3
E3
X4
E4
X5
E5
Conditional Independence
ƒ HMMs have two important independence properties:
ƒ Markov hidden process, future depends on past via the present
ƒ Current observation independent of all else given current state
X1
X2
X3
X4
X5
E1
E2
E3
E4
E5
ƒ An HMM is
ƒ Initial distribution:
ƒ Transitions:
ƒ Emissions:
Forward Algorithm
ƒ Can ask the same questions for HMMs as Markov chains
ƒ Given current belief state, how to update with evidence?
ƒ This is called monitoring or filtering
ƒ Formally, we want:
ƒ Quiz: does this mean that observations are independent
given no evidence?
ƒ [No, correlated by the hidden state]
4
Example
Viterbi Algorithm
ƒ Question: what is the most likely state sequence given
the observations?
ƒ Slow answer: enumerate all possibilities
ƒ Better answer: cached incremental version
Example
Real HMM Examples
ƒ Speech recognition HMMs:
ƒ Observations are acoustic signals (continuous valued)
ƒ States are specific positions in specific words (so, tens of
thousands)
ƒ Machine translation HMMs:
ƒ Observations are words (tens of thousands)
ƒ States are translation positions (dozens)
ƒ Robot tracking:
ƒ Observations are range readings (continuous)
ƒ States are positions on a map (continuous)
5