hidden markov models usman roshan cs 675 machine learning

17
Hidden Markov Models Usman Roshan CS 675 Machine Learning

Upload: cynthia-barrett

Post on 02-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Hidden Markov Models

Usman Roshan

CS 675

Machine Learning

Page 2: Hidden Markov Models Usman Roshan CS 675 Machine Learning

HMM applications

• Determine coding and non-coding regions in DNA sequences

• Separating “bad” pixels from “good” ones in image files

• Classification of DNA sequences

Page 3: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Hidden Markov Models

• Alphabet of symbols:

• Set of states that emit symbols from the alphabet:

• Set of probabilities– State transition: – Emission probabilities:

Page 4: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Loaded die problem

Page 5: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Loaded die automata

F L

aFL

aLF

eF(i) eL(i)

aFF aLL

Page 6: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Loaded die problem

• Consider the following rolls:

Observed : 21665261

Underlying die : FFLLFLLF• What is the probability that the

underlying path generated the observed sequence?

Page 7: Hidden Markov Models Usman Roshan CS 675 Machine Learning

HMM computational problems

Hidden sequence known

Hidden sequence unknown

Transition and emission probabilities known

Model fully specified

Viterbi to determine optimal hidden sequence

Transition and emission probabilities unknown

Maximum likelihood

Expected maximization and also known as Baum-Welch

Page 8: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Probabilities unknown but hidden sequence known

• Akl: number of transitions from state k to l

• Ek(b): number of times state k emits symbol b

Page 9: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Probabilities known but hidden sequence unknown

• Problem: Given an HMM and a sequence of rolls, find the most probably underlying generating path.

• Let be the sequence of rolls.• Let VF(i) denote the probability of the

most probable path of that ends in state F. (Define VL(i) similarly.)

Page 10: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Probabilities known but hidden sequence unknown

• Initialize:• Recurrence: for i=0..n-1

Page 11: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Probabilities and hidden sequence unknown

• Use Expected-Maximization algorithm (also known as EM algorithm)

• Very popular and many applications• For HMMs also called Baum-Welch algorithm• Outline:

1. Start with random assignment to transition and emission probabilities

2. Find expected transition and emission probabilities3. Estimate actual transition and emission probabilities from expected

values in previous step4. Go to step 2 if probabilities not converged

Page 12: Hidden Markov Models Usman Roshan CS 675 Machine Learning

HMM forward probabilities• Consider the total probability of all hidden sequences under a given

HMM.

• Let fL(i) be the sum of the probabilities of all hidden sequences upto i that end in the state L.

• Then fL(i) is given by

• We calculate fF(i) in the same way.

• We call these forward probabilities: – f(i) = fL(i)+fF(i)+fB(i)

Page 13: Hidden Markov Models Usman Roshan CS 675 Machine Learning

HMM backward probabilities

• Similarly we can calculate backward probabilties bL(i).

• Let bL(i) be the sum of the probabilities of all hidden sequences from i to the end that start in state L.

• Then bL(i) is given by

• We calculate bF(i) in the same way.

• We call these forward probabilities: – b(i) = bL(i)+bF(i)+bB(i)

Page 14: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Baum Welch

• How do we calculate expected transition and emission probabilities?

• Consider the fair-loaded die problem. What is the expected transition of fair (F) to loaded (L)?

• To answer we have to count the number of times F transitions to L in all possible hidden sequences and multiply each by the probability of the hidden sequence

Page 15: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Baum Welch

• For example suppose input is 12• What are the different hidden sequences?• What is the probability of each?• What is the total probability?• What is the probability of all hidden sequences

where the first state is F?• Can we determine these answers automatically

with forward and backward probabilities?

Page 16: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Baum WelchGeneral formula for expected number of transitionsfrom state k to l.

General formula for expected number of emissionsof b from state k.

Equations from Durbin et. al., 1998

Page 17: Hidden Markov Models Usman Roshan CS 675 Machine Learning

Baum Welch

1. Initialize random values for all parameters

2. Calculate forward and backward probabilities

3. Calculate new model parameters

4. Did the new probabilities (parameters) change by more than 0.001? If yes goto step 2. Otherwise stop.