6.864: Lecture 5 (September 22nd, 2005) The EM Algorithm

Size: px
Start display at page:

Download "6.864: Lecture 5 (September 22nd, 2005) The EM Algorithm"

Transcription

1 6.864: Lecture 5 (September 22nd, 2005) The EM Algorithm

2 Overview The EM algorithm in general form The EM algorithm for hidden markov models (brute force) The EM algorithm for hidden markov models (dynamic programming)

3 An Experiment/Some Intuition I have three coins in my pocket, Coin 0 has probability λ of heads; Coin 1 has probability p 1 of heads; Coin 2 has probability p 2 of heads For each trial I do the following: First I toss Coin 0 If Coin 0 turns up heads, I toss coin 1 three times If Coin 0 turns up tails, I toss coin 2 three times I don t tell you whether Coin 0 came up heads or tails, or whether Coin 1 or 2 was tossed three times, but I do tell you how many heads/tails are seen at each trial you see the following sequence: HHH, T T T, HHH, T T T, HHH What would you estimate as the values for λ, p 1 and p 2?

4 Maximum Likelihood Estimation We have data points x 1, x 2,... x n drawn from some (finite or countable) set X We have a parameter vector Θ We have a parameter space Ω We have a distribution P (x Θ) for any Θ Ω, such that P (x Θ) = 1 and P (x Θ) 0 for all x x X We assume that our data points x 1, x 2,... x n are drawn at random (independently, identically distributed) from a distribution P (x Θ ) for some Θ Ω

5 Log-Likelihood We have data points x 1, x 2,... x n drawn from some (finite or countable) set X We have a parameter vector Θ, and a parameter space Ω We have a distribution P (x Θ) for any Θ Ω The likelihood is n Likelihood(Θ) = P (x 1, x 2,... x n Θ) = P (x i Θ) i=1 The log-likelihood is n L(Θ) = log Likelihood(Θ) = log P (x i Θ) i=1

6 A First Example: Coin Tossing X = {H,T}. Our data points x 1, x 2,... x n are a sequence of heads and tails, e.g. HHTTHHHTHH Parameter vector Θ is a single parameter, i.e., the probability of coin coming up heads Parameter space Ω = [0, 1] Distribution P (x Θ) is defined as P (x Θ) = { Θ If x = H 1 Θ If x = T

7 Maximum Likelihood Estimation Given a sample x 1, x 2,... x n, choose Θ ML = argmax Θ Ω L(Θ) = argmax Θ Ω log P (x i Θ) i For example, take the coin example: say x 1... x n has Count(H) heads, and (n Count(H)) tails L(Θ) = ( ) log Θ Count(H) (1 Θ) n Count(H) = Count(H) log Θ + (n Count(H)) log(1 Θ) We now have Θ ML = Count(H) n

8 A Second Example: Probabilistic Context-Free Grammars X is the set of all parse trees generated by the underlying context-free grammar. Our sample is n trees T 1... T n such that each T i X. R is the set of rules in the context free grammar N is the set of non-terminals in the grammar Θ r for r R is the parameter for rule r Let R(α) R be the rules of the form α β for some β The parameter space Ω is the set of Θ [0, 1] R such that for all α N Θ r = 1 r R(α)

9 We have P (T Θ) = r R Count(T,r) Θr where Count(T, r) is the number of times rule r is seen in the tree T log P (T Θ) = Count(T, r) log Θ r r R

10 Maximum Likelihood Estimation for PCFGs We have log P (T Θ) = r R Count(T, r) log Θ r where Count(T, r) is the number of times rule r is seen in the tree T And, L(Θ) = log P (T i Θ) = Count(T i, r) log Θ r i i r R Solving Θ ML = argmax Θ Ω L(Θ) gives i Count(T i, r) Θ r = i s R(α) Count(T i, s) where r is of the form α β for some β

11 Multinomial Distributions X is a finite set, e.g., X = {dog, cat, the, saw} Our sample x 1, x 2,... x n is drawn from X e.g., x 1, x 2, x 3 = dog, the, saw The parameter Θ is a vector in R m where m = X e.g., Θ 1 = P (dog), Θ 2 = P (cat), Θ 3 = P (the), Θ 4 = P (saw) The parameter space is m Ω = {Θ : Θ i = 1 and i, Θ i 0} i=1 If our sample is x 1, x 2, x 3 = dog, the, saw, then L(Θ) = log P (x 1, x 2, x 3 = dog, the, saw) = log Θ 1 +log Θ 3 +log Θ 4

12 Models with Hidden Variables Now say we have two sets X and Y, and a joint distribution P (x, y Θ) If we had fully observed data, (x i, y i ) pairs, then L(Θ) = log P (x i, y i Θ) i If we have partially observed data, x i examples, then L(Θ) = log P (x i Θ) i = log P (x i, y Θ) i y Y

13 The EM (Expectation Maximization) algorithm is a method for finding Θ ML = argmax Θ log P (x i, y Θ) i y Y

14 The Three Coins Example e.g., in the three coins example: Y = {H,T} X = {HHH,TTT,HTT,THH,HHT,TTH,HTH,THT} Θ = {λ, p 1, p 2 } and where and P (x, y Θ) = P (y Θ)P (x y, Θ) { P (y Θ) = P (x y, Θ) = { λ If y = H 1 λ If y = T h 1 h 2 p (1 p 1 ) p (1 ) p 2 t t If y = H If y = T where h = number of heads in x, t = number of tails in x

15 The Three Coins Example Various probabilities can be calculated, for example: P (x = THT, y = H Θ) = λp 1 (1 p 1 ) 2 P (x = THT, y = T Θ) = (1 λ)p 2 (1 p 2 ) 2 P (x = THT Θ) = P (x = THT, y = H Θ) +P (x = THT, y = T Θ) = λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2 P (y = H x = THT, Θ) = = P (x = THT, y = H Θ) P (x = THT Θ) λp 1 (1 p 1 ) 2 λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2

16 The Three Coins Example Various probabilities can be calculated, for example: P (x = THT, y = H Θ) = λp 1 (1 p 1 ) 2 P (x = THT, y = T Θ) = (1 λ)p 2 (1 p 2 ) 2 P (x = THT Θ) = P (x = THT, y = H Θ) +P (x = THT, y = T Θ) = λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2 P (y = H x = THT, Θ) = = P (x = THT, y = H Θ) P (x = THT Θ) λp 1 (1 p 1 ) 2 λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2

17 The Three Coins Example Various probabilities can be calculated, for example: P (x = THT, y = H Θ) = λp 1 (1 p 1 ) 2 P (x = THT, y = T Θ) = (1 λ)p 2 (1 p 2 ) 2 P (x = THT Θ) = P (x = THT, y = H Θ) +P (x = THT, y = T Θ) = λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2 P (y = H x = THT, Θ) = = P (x = THT, y = H Θ) P (x = THT Θ) λp 1 (1 p 1 ) 2 λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2

18 The Three Coins Example Various probabilities can be calculated, for example: P (x = THT, y = H Θ) = λp 1 (1 p 1 ) 2 P (x = THT, y = T Θ) = (1 λ)p 2 (1 p 2 ) 2 P (x = THT Θ) = P (x = THT, y = H Θ) +P (x = THT, y = T Θ) = λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2 P (y = H x = THT, Θ) = = P (x = THT, y = H Θ) P (x = THT Θ) λp 1 (1 p 1 ) 2 λp 1 (1 p 1 ) 2 + (1 λ)p 2 (1 p 2 ) 2

19 The Three Coins Example Fully observed data might look like: ( HHH, H), ( T T T, T ), ( HHH, H), ( T T T, T ), ( HHH, H) In this case maximum likelihood estimates are: 3 λ = 5 9 p 1 = 9 0 p 2 = 6

20 The Three Coins Example Partially observed data might look like: HHH, T T T, HHH, T T T, HHH How do we find the maximum likelihood parameters?

21 The Three Coins Example Partially observed data might look like: HHH, T T T, HHH, T T T, HHH If current parameters are λ, p 1, p 2 P ( HHH, H) P (y = H x = HHH ) = P ( HHH, H) + P ( HHH, T) = λp 3 1 λp (1 λ)p 3 2 P (y = H x = TTT ) = = P ( TTT, H) P ( TTT, H) + P ( TTT, T) λ(1 p 1 ) 3 λ(1 p 1 ) 3 + (1 λ)(1 p 2 ) 3

22 The Three Coins Example If current parameters are λ, p 1, p 2 λp 3 P (y = H x = HHH ) = 1 λp (1 λ)p 3 2 P (y = H x = TTT ) = λ(1 p 1 ) 3 λ(1 p 1 ) 3 + (1 λ)(1 p 2 ) 3 If λ = 0.3, p 1 = 0.3, p 2 = 0.6: P (y = H x = HHH ) = P (y = H x = TTT ) =

23 The Three Coins Example After filling in hidden variables for each example, partially observed data might look like: ( HHH, H) P (y = H HHH) = ( HHH, T ) P (y = T HHH) = ( TTT, H) P (y = H TTT) = ( TTT, T ) P (y = T TTT) = ( HHH, H) P (y = H HHH) = ( HHH, T ) P (y = T HHH) = ( TTT, H) P (y = H TTT) = ( TTT, T ) P (y = T TTT) = ( HHH, H) P (y = H HHH) = ( HHH, T ) P (y = T HHH) =

24 New Estimates: The Three Coins Example ( HHH, H) P (y = H HHH) = ( HHH, T ) P (y = T HHH) = ( TTT, H) P (y = H TTT) = ( TTT, T ) P (y = T TTT) = λ = = p 1 = = p 2 = =

25 The Three Coins Example: Summary Begin with parameters λ = 0.3, p 1 = 0.3, p 2 = 0.6 Fill in hidden variables, using P (y = H x = HHH ) = P (y = H x = TTT ) = Re-estimate parameters to be λ = , p 1 = , p 2 =

26 Iteration λ p 1 p 2 p 1 p 2 p 3 p The coin example for y = { HHH, T T T, HHH, T T T }. The solution that EM reaches is intuitively correct: the coin-tosser has two coins, one which always shows up heads, the other which always shows tails, and is picking between them with equal probability (λ = 0.5). The posterior probabilities p i show that we are certain that coin 1 (tail-biased) generated y 2 and y 4, whereas coin 2 generated y 1 and y 3.

27 Iteration λ p 1 p 2 p 1 p 2 p 3 p 4 p The coin example for { HHH, T T T, HHH, T T T, HHH }. λ is now 0.4, indicating that the coin-tosser has probability 0.4 of selecting the tail-biased coin.

28 Iteration λ p 1 p 2 p 1 p 2 p 3 p The coin example for y = { HHT, T T T, HHH, T T T }. EM selects a tails-only coin, and a coin which is heavily heads-biased (p 2 = ). It s certain that y 1 and y 3 were generated by coin 2, as they contain heads. y 2 and y 4 could have been generated by either coin, but coin 1 is far more likely.

29 Iteration λ p 1 p 2 p 1 p 2 p 3 p The coin example for y = { HHH, T T T, HHH, T T T }, with p 1 and p 2 initialised to the same value. EM is stuck at a saddle point

30 Iteration λ p 1 p 2 p 1 p 2 p 3 p The coin example for y = { HHH, T T T, HHH, T T T }. If we initialise p 1 and p 2 to be a small amount away from the saddle point p 1 = p 2, the algorithm diverges from the saddle point and eventually reaches the global maximum.

31 Iteration λ p 1 p 2 p 1 p 2 p 3 p The coin example for y = { HHH, T T T, HHH, T T T }. If we initialise p 1 and p 2 to be a small amount away from the saddle point p 1 = p 2, the algorithm diverges from the saddle point and eventually reaches the global maximum.

32 The EM Algorithm Θ t is the parameter vector at t th iteration Choose Θ 0 (at random, or using various heuristics) Iterative procedure is defined as where Θ t = argmax Θ Q(Θ, Θ t 1 ) Q(Θ, Θ t 1 ) = P (y x i, Θ t 1 ) log P (x i, y Θ) i y Y

33 The EM Algorithm t Iterative procedure is defined as Θ = argmax Θ Q(Θ, Θ t 1 ), where Q(Θ, Θ t 1 ) = P (y x i, Θ t 1 ) log P (x i, y Θ) Key points: i y Y Intuition: fill in hidden variables y according to P (y x i, Θ) EM is guaranteed to converge to a local maximum, or saddle-point, of the likelihood function In general, if argmax Θ log P (x i, y i Θ) i has a simple (analytic) solution, then argmax Θ P (y x i, Θ) log P (x i, y Θ) also has a simple (analytic) solution. i y

34 Overview The EM algorithm in general form The EM algorithm for hidden markov models (brute force) The EM algorithm for hidden markov models (dynamic programming)

35 The Structure of Hidden Markov Models Have N states, states 1... N Without loss of generality, take N to be the final or stop state Have an alphabet K. For example K = {a, b} Parameter λ i for i = 1... N is probability of starting in state i Parameter a i,j for i = 1... (N 1), and j = 1... N is probability of state j following state i Parameter b i (o) for i = 1... (N 1), and o K is probability of state i emitting symbol o

36 An Example Take N = 3 states. States are {1, 2, 3}. Final state is state 3. Alphabet K = {the, dog}. Distribution over initial state is λ 1 = 1.0, λ 2 = 0, λ 3 = 0. Parameters a i,j are j=1 j=2 j=3 i= i= Parameters b i (o) are o=the o=dog i= i=

37 A Generative Process Pick the start state s 1 to be state i for i = 1... N with probability λ i. Set t = 1 Repeat while current state s t is not the stop state (N): Emit a symbol o t K with probability b st (o t ) Pick the next state s t+1 as state j with probability a st,j. t = t + 1

38 Probabilities Over Sequences An output sequence is a sequence of observations o 1... o T where each o i K e.g. the dog the dog dog the A state sequence is a sequence of states s 1... s T where each s i {1... N} e.g HMM defines a probability for each state/output sequence pair e.g. the/1 dog/2 the/1 dog/2 the/2 dog/1 has probability λ 1 b 1 (the) a 1,2 b 2 (dog) a 2,1 b 1 (the) a 1,2 b 2 (dog) a 2,2 b 2 (the) a 2,1 b 1 (dog)a 1,3 Formally: ( ) ( ) T T P (s 1... s T, o 1... o T ) = λ s 1 P (s i s i 1 ) P (o i s i ) P (N s T ) i=2 i=1

39 A Hidden Variable Problem We have an HMM with N = 3, K = {e, f, g, h} We see the following output sequences in training data e e f f g h h g How would you choose the parameter values for λ i, a i,j, and b i (o)?

40 Another Hidden Variable Problem We have an HMM with N = 3, K = {e, f, g, h} We see the following output sequences in training data e g h e h f h g f g g e h How would you choose the parameter values for λ i, a i,j, and b i (o)?

41 A Reminder: Models with Hidden Variables Now say we have two sets X and Y, and a joint distribution P (x, y Θ) If we had fully observed data, (x i, y i ) pairs, then L(Θ) = log P (x i, y i Θ) i If we have partially observed data, x i examples, then L(Θ) = log P (x i Θ) i = log P (x i, y Θ) i y Y

42 Hidden Markov Models as a Hidden Variable Problem We have two sets X and Y, and a joint distribution P (x, y Θ) In Hidden Markov Models: each x X is an output sequence o 1... o T each y Y is a state sequence s 1... s T

43 Maximum Likelihood Estimates We have an HMM with N = 3, K = {e, f, g, h} We see the following paired sequences in training data e/1 g/2 e/1 h/2 f/1 h/2 f/1 g/2 Maximum likelihood estimates: for parameters a i,j : for parameters b i (o): λ 1 = 1.0, λ 2 = 0.0, λ 3 = 0.0 j=1 j=2 j=3 i= i= o=e o=f o=g o=h i= i=

44 The Likelihood Function for HMMs: Fully Observed Data Say (x, y) = {o 1... o T, s 1... s T }, and f (i, j, x, y) = Number of times state j follows state i in (x,y) f (i, x, y) = Number of times state i is the initial state in (x,y) (1 or 0) f (i, o, x, y) = Number of times state i is paired with observation o Then P (x, y) = f (i,x,y) λ i a f (i,j,x,y) i,j i {1...N 1} i {1...N 1}, i {1...N 1}, j {1...N } o K b i (o) f (i,o,x,y)

45 The Likelihood Function for HMMs: Fully Observed Data If we have training examples (x l, y l ) for l = 1... m, m L(Θ) = log P (x l, y l ) l=1 m = f(i, x l, y l ) log λ i + l=1 i {1...N 1} f(i, j, x l, y l ) log a i,j + i {1...N 1}, j {1...N } f(i, o, x l, y l ) log b i (o) i {1...N 1}, o K

46 Maximizing this function gives maximum-likelihood estimates: l f(i, x l, y l ) λ i = l k f(k, x l, y l ) l f(i, j, x l, y l ) a i,j = l k f(i, k, x l, y l ) l f(i, o, x l, y l ) b i (o) = l o K f(i, o, x l, y l )

47 The Likelihood Function for HMMs: Partially Observed Data If we have training examples (x l ) for l = 1... m, m L(Θ) = log P (x l, y) y l=1 m Q(Θ, Θ t 1 ) = P (y x l, Θ t 1 ) log P (x l, y Θ) y l=1

48 m Q(Θ, Θ t 1 ) = P (y x l, Θ t 1 ) f(i, x l, y) log λ i + l=1 y i {1...N 1} f(i, j, x l, y) log a i,j + f(i, o, x l, y) log b i (o) i {1...N 1}, j {1...N } i {1...N 1}, o K m = g(i, x l ) log λ i + g(i, j, x l ) log a i,j + g(i, o, x l ) log b i (o) l=1 i {1...N 1} i {1...N 1}, i {1...N 1}, j {1...N } o K where each g is an expected count: g(i, x l ) = P (y x l, Θ t 1 )f(i, x l, y) y g(i, j, x l ) = P (y x l, Θ t 1 )f(i, j, x l, y) y g(i, o, x l ) = P (y x l, Θ t 1 )f(i, o, x l, y) y

49 Maximizing this function gives EM updates: l g(i, x l) l g(i, j, x l) l g(i, o, x l) λ i = a i,j = b i (o) = l k g(k, x l) l k g(i, k, x l) l o K g(i, o, x l ) Compare this to maximum likelihood estimates in fully observed case: l f(i, x l, y l ) l f(i, j, x l, y l ) f(i, o, x l, y l ) λ i = a i,j = b i (o) = l f(k, x l, y l ) f(i, k, x l, y l ) f(i, o, x l, y l ) l k l k l o K

50 A Hidden Variable Problem We have an HMM with N = 3, K = {e, f, g, h} We see the following output sequences in training data e e f f g h h g How would you choose the parameter values for λ i, a i,j, and b i (o)?

51 Four possible state sequences for the first example: e/1 g/1 e/1 g/2 e/2 g/1 e/2 g/2

52 Four possible state sequences for the first example: e/1 g/1 e/1 g/2 e/2 g/1 e/2 g/2 Each state sequence has a different probability: e/1 g/1 λ 1 a 1,1 a 1,3 b 1 (e)b 1 (g) e/1 g/2 λ 1 a 1,2 a 2,3 b 1 (e)b 2 (g) e/2 g/1 λ 2 a 2,1 a 1,3 b 2 (e)b 1 (g) e/2 g/2 λ 2 a 2,2 a 2,3 b 2 (e)b 2 (g)

53 A Hidden Variable Problem Say we have initial parameter values: λ 1 = 0.35, λ 2 = 0.3, λ 3 = 0.35 a i,j j=1 j=2 j=3 i= i= b i (o) o=e o=f o=g o=h i= i= Each state sequence has a different probability: e/1 g/1 λ 1 a 1,1 a 1,3 b 1 (e)b 1 (g) = e/1 g/2 λ 1 a 1,2 a 2,3 b 1 (e)b 2 (g) = e/2 g/1 λ 2 a 2,1 a 1,3 b 2 (e)b 1 (g) = e/2 g/2 λ 2 a 2,2 a 2,3 b 2 (e)b 2 (g) =

54 A Hidden Variable Problem Each state sequence has a different probability: e/1 g/1 λ 1 a 1,1 a 1,3 b 1 (e)b 1 (g) = e/1 g/2 λ 1 a 1,2 a 2,3 b 1 (e)b 2 (g) = e/2 g/1 λ 2 a 2,1 a 1,3 b 2 (e)b 1 (g) = e/2 g/2 λ 2 a 2,2 a 2,3 b 2 (e)b 2 (g) = Each state sequence has a different conditional probability, e.g.: P (1 1 e g, Θ) = = e/1 g/1 P (1 1 e g, Θ) = 0.28 e/1 g/2 P (1 2 e g, Θ) = 0.42 e/2 g/1 P (2 1 e g, Θ) = 0.18 e/2 g/2 P (2 2 e g, Θ) = 0.12

55 fill in hidden values for (e g), (e h), (f h), (f g) e/1 g/1 P (1 1 e g, Θ) = 0.28 e/1 g/2 P (1 2 e g, Θ) = 0.42 e/2 g/1 P (2 1 e g, Θ) = 0.18 e/2 g/2 P (2 2 e g, Θ) = 0.12 e/1 h/1 P (1 1 e h, Θ) = e/1 h/2 P (1 2 e h, Θ) = e/2 h/1 P (2 1 e h, Θ) = e/2 h/2 P (2 2 e h, Θ) = f/1 h/1 P (1 1 f h, Θ) = f/1 h/2 P (1 2 f h, Θ) = f/2 h/1 P (2 1 f h, Θ) = f/2 h/2 P (2 2 f h, Θ) = f/1 g/1 P (1 1 f g, Θ) = f/1 g/2 P (1 2 f g, Θ) = f/2 g/1 P (2 1 f g, Θ) = f/2 g/2 P (2 2 f g, Θ) = 0.162

56 Calculate the expected counts: g(1, xl ) = = l g(2, xl ) = l g(3, xl ) = 0.0 l g(1, 1, xl ) = = l g(1, 2, xl ) = 1.72 l g(2, 1, xl ) = l g(2, 2, xl ) = l g(1, 3, xl ) = l g(2, 3, xl ) = l

57 Calculate the expected counts: g(1, e, x l ) = = 1.4 l g(1, f, x l ) = l g(1, g, x l ) = l g(1, h, x l ) = l g(2, e, x l ) = 0.6 l g(2, f, x l ) = l g(2, g, x l ) = l g(2, h, x l ) = l

58 Calculate the new estimates: l g(1, x l) λ 1 = = = l g(1, x l) + l g(2, x l) + l g(3, x l) λ 2 = λ 3 = 0 l g(1, 1, x l) 0.91 a 1,1 = = = l g(1, 1, x l) + l g(1, 2, x l) + l g(1, 3, x l ) a i,j j=1 j=2 j=3 i= i= b i (o) o=e o=f o=g o=h i= i=

59 Iterate this 3 times: λ 1 = , λ 2 = λ 3 = 0 a i,j j=1 j=2 j=3 i= i= b i (o) o=e o=f o=g o=h i= i=

60 Overview The EM algorithm in general form The EM algorithm for hidden markov models (brute force) The EM algorithm for hidden markov models (dynamic programming)

61 The Forward-Backward or Baum-Welch Algorithm Aim is to (efficiently!) calculate the expected counts: g(i, x l ) = P (y xl, Θ t 1 )f(i, x l, y) y g(i, j, x l ) = P (y xl, Θ t 1 )f(i, j, x l, y) y g(i, o, x l ) = P (y xl, Θ t 1 )f(i, o, x l, y) y

62 The Forward-Backward or Baum-Welch Algorithm Suppose we could calculate the following quantities, given an input sequence o 1... o T : α i (t) = P (o 1... o t 1, s t = i Θ) forward probabilities β i (t) = P (o t... o T s t = i, Θ) backward probabilities The probability of being in state i at time t, is p t (i) = P (s t = i o 1... o T, Θ) = P (s t = i, o 1... o T Θ) P (o 1... o T Θ) also, α t (i)β t (i) = P (o 1... o T Θ) P (o 1... o T Θ) = α t (i)β t (i) for any t i

63 Expected Initial Counts As before, g(i, o 1... o T ) = expected number of times state i is state 1 We can calculate this as g(i, o 1... o T ) = p 1 (i)

64 Expected Emission Counts As before, g(i, o, o 1... o T ) = expected number of times state i emits the symbol o We can calculate this as g(i, o, o 1... o T ) = t:o t =o p t (i)

65 The Forward-Backward or Baum-Welch Algorithm Suppose we could calculate the following quantities, given an input sequence o 1... o T : α i (t) = P (o 1... o t 1, s t = i Θ) forward probabilities β i (t) = P (o t... o T s t = i, Θ) backward probabilities The probability of being in state i at time t, and in state j at time t + 1, is p t (i, j) = P (s t = i, s t+1 = j o 1... o T, Θ) = P (s t = i, s t+1 = j, o 1... o T Θ) P (o 1... o T Θ) also, α t (i)a i,j b i (o t )β t+1 (j) = P (o 1... o T Θ) P (o 1... o T Θ) = α t (i)β t (i) for any t i

66 As before, Expected Transition Counts g(i, j, o 1... o T ) = expected number of times state j follows state i We can calculate this as g(i, j, o 1... o T ) = p t (i, j) t

67 Recursive Definitions for Forward Probabilities Given an input sequence o 1... o T : α i (t) = P (o 1... o t 1, s t = i Θ) forward probabilities Base case: α i (1) = λ i for all i Recursive case: α j (t+1) = α i (t)a i,j b i (o t ) for all j = 1... N and t = 2... T i

68 Recursive Definitions for Backward Probabilities Given an input sequence o 1... o T : β i (t) = P (o t... o T s t = i, Θ) backward probabilities Base case: β i (T + 1) = 1 β i (T + 1) = 0 for i = N for i = N Recursive case: β i (t) = a i,j b i (o t )β j (t+1) for all j = 1... N and t = 1... T j

69 Overview The EM algorithm in general form (more about the 3 coin example) The EM algorithm for hidden markov models (brute force) The EM algorithm for hidden markov models (dynamic programming) Briefly: The EM algorithm for PCFGs

70 EM for Probabilistic Context-Free Grammars A PCFG defines a distribution P (S, T Θ) over tree/sentence pairs (S, T ) If we had tree/sentence pairs (fully observed data) then L(Θ) = log P (S i, T i Θ) i Say we have sentences only, S 1... S n trees are hidden variables L(Θ) = log P (S i, T Θ) i T

71 EM for Probabilistic Context-Free Grammars Say we have sentences only, S 1... S n trees are hidden variables L(Θ) = log P (S i, T Θ) i T EM algorithm is then Θ t = argmax Θ Q(Θ, Θ t 1 ), where Q(Θ, Θ t 1 ) = P (T S i, Θ t 1 ) log P (S i, T Θ) i T

72 Remember: log P (S i, T Θ) = r R Count(S i, T, r) log Θ r where Count(S, T, r) is the number of times rule r is seen in the sentence/tree pair (S, T ) Q(Θ, Θ t 1 ) = P (T S i, Θ t 1 ) log P (S i, T Θ) i T = P (T S i, Θ t 1 ) Count(S i, T, r) log Θ r i T r R = Count(S i, r) log Θ r i r R where Count(S i, r) = T P (T S i, Θ t 1 )Count(S i, T, r) the expected counts

73 Solving Θ ML = argmax Θ Ω L(Θ) gives i Count(S i, α β) Θ α β = i s R(α) Count(S i, s) There are efficient algorithms for calculating Count(S i, r) = P (T S i, Θ t 1 )Count(S i, T, r) T for a PCFG. See (Baker 1979), called The Inside Outside Algorithm. See also Manning and Schuetze section

An Experiment/Some Intuition (Fall 2006): Lecture 18 The EM Algorithm heads coin 1 tails coin 2 Overview Maximum Likelihood Estimation

An Experiment/Some Intuition (Fall 2006): Lecture 18 The EM Algorithm heads coin 1 tails coin 2 Overview Maximum Likelihood Estimation An Experment/Some Intuton I have three cons n my pocket, 6.864 (Fall 2006): Lecture 18 The EM Algorthm Con 0 has probablty λ of heads; Con 1 has probablty p 1 of heads; Con 2 has probablty p 2 of heads

More information

6.891: Lecture 8 (October 1st, 2003) Log-Linear Models for Parsing, and the EM Algorithm Part I

6.891: Lecture 8 (October 1st, 2003) Log-Linear Models for Parsing, and the EM Algorithm Part I 6.891: Lecture 8 (October 1st, 2003) Log-Linear Models for Parsing, and EM Algorithm Part I Overview Ratnaparkhi s Maximum-Entropy Parser The EM Algorithm Part I Log-Linear Taggers: Independence Assumptions

More information

O 3 O 4 O 5. q 3. q 4. Transition

O 3 O 4 O 5. q 3. q 4. Transition Hidden Markov Models Hidden Markov models (HMM) were developed in the early part of the 1970 s and at that time mostly applied in the area of computerized speech recognition. They are first described in

More information

Hidden Markov Model. Ying Wu. Electrical Engineering and Computer Science Northwestern University Evanston, IL 60208

Hidden Markov Model. Ying Wu. Electrical Engineering and Computer Science Northwestern University Evanston, IL 60208 Hidden Markov Model Ying Wu Electrical Engineering and Computer Science Northwestern University Evanston, IL 60208 http://www.eecs.northwestern.edu/~yingwu 1/19 Outline Example: Hidden Coin Tossing Hidden

More information

Lecture 4: Hidden Markov Models: An Introduction to Dynamic Decision Making. November 11, 2010

Lecture 4: Hidden Markov Models: An Introduction to Dynamic Decision Making. November 11, 2010 Hidden Lecture 4: Hidden : An Introduction to Dynamic Decision Making November 11, 2010 Special Meeting 1/26 Markov Model Hidden When a dynamical system is probabilistic it may be determined by the transition

More information

Lecture 9. Intro to Hidden Markov Models (finish up)

Lecture 9. Intro to Hidden Markov Models (finish up) Lecture 9 Intro to Hidden Markov Models (finish up) Review Structure Number of states Q 1.. Q N M output symbols Parameters: Transition probability matrix a ij Emission probabilities b i (a), which is

More information

Hidden Markov Models The three basic HMM problems (note: change in notation) Mitch Marcus CSE 391

Hidden Markov Models The three basic HMM problems (note: change in notation) Mitch Marcus CSE 391 Hidden Markov Models The three basic HMM problems (note: change in notation) Mitch Marcus CSE 391 Parameters of an HMM States: A set of states S=s 1, s n Transition probabilities: A= a 1,1, a 1,2,, a n,n

More information

Lecture 12: Algorithms for HMMs

Lecture 12: Algorithms for HMMs Lecture 12: Algorithms for HMMs Nathan Schneider (some slides from Sharon Goldwater; thanks to Jonathan May for bug fixes) ENLP 17 October 2016 updated 9 September 2017 Recap: tagging POS tagging is a

More information

CISC 889 Bioinformatics (Spring 2004) Hidden Markov Models (II)

CISC 889 Bioinformatics (Spring 2004) Hidden Markov Models (II) CISC 889 Bioinformatics (Spring 24) Hidden Markov Models (II) a. Likelihood: forward algorithm b. Decoding: Viterbi algorithm c. Model building: Baum-Welch algorithm Viterbi training Hidden Markov models

More information

Recap: HMM. ANLP Lecture 9: Algorithms for HMMs. More general notation. Recap: HMM. Elements of HMM: Sharon Goldwater 4 Oct 2018.

Recap: HMM. ANLP Lecture 9: Algorithms for HMMs. More general notation. Recap: HMM. Elements of HMM: Sharon Goldwater 4 Oct 2018. Recap: HMM ANLP Lecture 9: Algorithms for HMMs Sharon Goldwater 4 Oct 2018 Elements of HMM: Set of states (tags) Output alphabet (word types) Start state (beginning of sentence) State transition probabilities

More information

Hidden Markov Models

Hidden Markov Models Hidden Markov Models Slides revised and adapted to Bioinformática 55 Engª Biomédica/IST 2005 Ana Teresa Freitas Forward Algorithm For Markov chains we calculate the probability of a sequence, P(x) How

More information

Lecture 12: Algorithms for HMMs

Lecture 12: Algorithms for HMMs Lecture 12: Algorithms for HMMs Nathan Schneider (some slides from Sharon Goldwater; thanks to Jonathan May for bug fixes) ENLP 26 February 2018 Recap: tagging POS tagging is a sequence labelling task.

More information

Hidden Markov Models. Three classic HMM problems

Hidden Markov Models. Three classic HMM problems An Introduction to Bioinformatics Algorithms www.bioalgorithms.info Hidden Markov Models Slides revised and adapted to Computational Biology IST 2015/2016 Ana Teresa Freitas Three classic HMM problems

More information

Lecture 15. Probabilistic Models on Graph

Lecture 15. Probabilistic Models on Graph Lecture 15. Probabilistic Models on Graph Prof. Alan Yuille Spring 2014 1 Introduction We discuss how to define probabilistic models that use richly structured probability distributions and describe how

More information

Markov Chains and Hidden Markov Models. COMP 571 Luay Nakhleh, Rice University

Markov Chains and Hidden Markov Models. COMP 571 Luay Nakhleh, Rice University Markov Chains and Hidden Markov Models COMP 571 Luay Nakhleh, Rice University Markov Chains and Hidden Markov Models Modeling the statistical properties of biological sequences and distinguishing regions

More information

L23: hidden Markov models

L23: hidden Markov models L23: hidden Markov models Discrete Markov processes Hidden Markov models Forward and Backward procedures The Viterbi algorithm This lecture is based on [Rabiner and Juang, 1993] Introduction to Speech

More information

Natural Language Processing Prof. Pushpak Bhattacharyya Department of Computer Science & Engineering, Indian Institute of Technology, Bombay

Natural Language Processing Prof. Pushpak Bhattacharyya Department of Computer Science & Engineering, Indian Institute of Technology, Bombay Natural Language Processing Prof. Pushpak Bhattacharyya Department of Computer Science & Engineering, Indian Institute of Technology, Bombay Lecture - 21 HMM, Forward and Backward Algorithms, Baum Welch

More information

An Introduction to Bioinformatics Algorithms Hidden Markov Models

An Introduction to Bioinformatics Algorithms   Hidden Markov Models Hidden Markov Models Outline 1. CG-Islands 2. The Fair Bet Casino 3. Hidden Markov Model 4. Decoding Algorithm 5. Forward-Backward Algorithm 6. Profile HMMs 7. HMM Parameter Estimation 8. Viterbi Training

More information

HMM: Parameter Estimation

HMM: Parameter Estimation I529: Machine Learning in Bioinformatics (Spring 2017) HMM: Parameter Estimation Yuzhen Ye School of Informatics and Computing Indiana University, Bloomington Spring 2017 Content Review HMM: three problems

More information

Expectation Maximization (EM)

Expectation Maximization (EM) Expectation Maximization (EM) The Expectation Maximization (EM) algorithm is one approach to unsupervised, semi-supervised, or lightly supervised learning. In this kind of learning either no labels are

More information

Dynamic Approaches: The Hidden Markov Model

Dynamic Approaches: The Hidden Markov Model Dynamic Approaches: The Hidden Markov Model Davide Bacciu Dipartimento di Informatica Università di Pisa bacciu@di.unipi.it Machine Learning: Neural Networks and Advanced Models (AA2) Inference as Message

More information

Hidden Markov Models. Ivan Gesteira Costa Filho IZKF Research Group Bioinformatics RWTH Aachen Adapted from:

Hidden Markov Models. Ivan Gesteira Costa Filho IZKF Research Group Bioinformatics RWTH Aachen Adapted from: Hidden Markov Models Ivan Gesteira Costa Filho IZKF Research Group Bioinformatics RWTH Aachen Adapted from: www.ioalgorithms.info Outline CG-islands The Fair Bet Casino Hidden Markov Model Decoding Algorithm

More information

Hidden Markov Models: All the Glorious Gory Details

Hidden Markov Models: All the Glorious Gory Details Hidden Markov Models: All the Glorious Gory Details Noah A. Smith Department of Computer Science Johns Hopkins University nasmith@cs.jhu.edu 18 October 2004 1 Introduction Hidden Markov models (HMMs, hereafter)

More information

Example: The Dishonest Casino. Hidden Markov Models. Question # 1 Evaluation. The dishonest casino model. Question # 3 Learning. Question # 2 Decoding

Example: The Dishonest Casino. Hidden Markov Models. Question # 1 Evaluation. The dishonest casino model. Question # 3 Learning. Question # 2 Decoding Example: The Dishonest Casino Hidden Markov Models Durbin and Eddy, chapter 3 Game:. You bet $. You roll 3. Casino player rolls 4. Highest number wins $ The casino has two dice: Fair die P() = P() = P(3)

More information

Part of Speech Tagging: Viterbi, Forward, Backward, Forward- Backward, Baum-Welch. COMP-599 Oct 1, 2015

Part of Speech Tagging: Viterbi, Forward, Backward, Forward- Backward, Baum-Welch. COMP-599 Oct 1, 2015 Part of Speech Tagging: Viterbi, Forward, Backward, Forward- Backward, Baum-Welch COMP-599 Oct 1, 2015 Announcements Research skills workshop today 3pm-4:30pm Schulich Library room 313 Start thinking about

More information

STA 414/2104: Machine Learning

STA 414/2104: Machine Learning STA 414/2104: Machine Learning Russ Salakhutdinov Department of Computer Science! Department of Statistics! rsalakhu@cs.toronto.edu! http://www.cs.toronto.edu/~rsalakhu/ Lecture 9 Sequential Data So far

More information

Hidden Markov Models

Hidden Markov Models Hidden Markov Models Outline 1. CG-Islands 2. The Fair Bet Casino 3. Hidden Markov Model 4. Decoding Algorithm 5. Forward-Backward Algorithm 6. Profile HMMs 7. HMM Parameter Estimation 8. Viterbi Training

More information

Expectation Maximization (EM)

Expectation Maximization (EM) Expectation Maximization (EM) The EM algorithm is used to train models involving latent variables using training data in which the latent variables are not observed (unlabeled data). This is to be contrasted

More information

Statistical NLP: Hidden Markov Models. Updated 12/15

Statistical NLP: Hidden Markov Models. Updated 12/15 Statistical NLP: Hidden Markov Models Updated 12/15 Markov Models Markov models are statistical tools that are useful for NLP because they can be used for part-of-speech-tagging applications Their first

More information

Cheng Soon Ong & Christian Walder. Canberra February June 2018

Cheng Soon Ong & Christian Walder. Canberra February June 2018 Cheng Soon Ong & Christian Walder Research Group and College of Engineering and Computer Science Canberra February June 2018 Outlines Overview Introduction Linear Algebra Probability Linear Regression

More information

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

Hidden Markov Models. By Parisa Abedi. Slides courtesy: Eric Xing Hidden Markov Models By Parisa Abedi Slides courtesy: Eric Xing i.i.d to sequential data So far we assumed independent, identically distributed data Sequential (non i.i.d.) data Time-series data E.g. Speech

More information

Outline. 1. Define likelihood 2. Interpretations of likelihoods 3. Likelihood plots 4. Maximum likelihood 5. Likelihood ratio benchmarks

Outline. 1. Define likelihood 2. Interpretations of likelihoods 3. Likelihood plots 4. Maximum likelihood 5. Likelihood ratio benchmarks Outline 1. Define likelihood 2. Interpretations of likelihoods 3. Likelihood plots 4. Maximum likelihood 5. Likelihood ratio benchmarks Likelihood A common and fruitful approach to statistics is to assume

More information

Hidden Markov Models. x 1 x 2 x 3 x K

Hidden Markov Models. x 1 x 2 x 3 x K Hidden Markov Models 1 1 1 1 2 2 2 2 K K K K x 1 x 2 x 3 x K Viterbi, Forward, Backward VITERBI FORWARD BACKWARD Initialization: V 0 (0) = 1 V k (0) = 0, for all k > 0 Initialization: f 0 (0) = 1 f k (0)

More information

CSCE 471/871 Lecture 3: Markov Chains and

CSCE 471/871 Lecture 3: Markov Chains and and and 1 / 26 sscott@cse.unl.edu 2 / 26 Outline and chains models (s) Formal definition Finding most probable state path (Viterbi algorithm) Forward and backward algorithms State sequence known State

More information

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

Hidden Markov Models. Aarti Singh Slides courtesy: Eric Xing. Machine Learning / Nov 8, 2010 Hidden Markov Models Aarti Singh Slides courtesy: Eric Xing Machine Learning 10-701/15-781 Nov 8, 2010 i.i.d to sequential data So far we assumed independent, identically distributed data Sequential data

More information

Multiple Sequence Alignment using Profile HMM

Multiple Sequence Alignment using Profile HMM Multiple Sequence Alignment using Profile HMM. based on Chapter 5 and Section 6.5 from Biological Sequence Analysis by R. Durbin et al., 1998 Acknowledgements: M.Sc. students Beatrice Miron, Oana Răţoi,

More information

Hidden Markov Models

Hidden Markov Models CS769 Spring 2010 Advanced Natural Language Processing Hidden Markov Models Lecturer: Xiaojin Zhu jerryzhu@cs.wisc.edu 1 Part-of-Speech Tagging The goal of Part-of-Speech (POS) tagging is to label each

More information

Hidden Markov Models. Hosein Mohimani GHC7717

Hidden Markov Models. Hosein Mohimani GHC7717 Hidden Markov Models Hosein Mohimani GHC7717 hoseinm@andrew.cmu.edu Fair et Casino Problem Dealer flips a coin and player bets on outcome Dealer use either a fair coin (head and tail equally likely) or

More information

CSCE 478/878 Lecture 9: Hidden. Markov. Models. Stephen Scott. Introduction. Outline. Markov. Chains. Hidden Markov Models. CSCE 478/878 Lecture 9:

CSCE 478/878 Lecture 9: Hidden. Markov. Models. Stephen Scott. Introduction. Outline. Markov. Chains. Hidden Markov Models. CSCE 478/878 Lecture 9: Useful for modeling/making predictions on sequential data E.g., biological sequences, text, series of sounds/spoken words Will return to graphical models that are generative sscott@cse.unl.edu 1 / 27 2

More information

STA 4273H: Statistical Machine Learning

STA 4273H: Statistical Machine Learning STA 4273H: Statistical Machine Learning Russ Salakhutdinov Department of Statistics! rsalakhu@utstat.toronto.edu! http://www.utstat.utoronto.ca/~rsalakhu/ Sidney Smith Hall, Room 6002 Lecture 11 Project

More information

p(d θ ) l(θ ) 1.2 x x x

p(d θ ) l(θ ) 1.2 x x x p(d θ ).2 x 0-7 0.8 x 0-7 0.4 x 0-7 l(θ ) -20-40 -60-80 -00 2 3 4 5 6 7 θ ˆ 2 3 4 5 6 7 θ ˆ 2 3 4 5 6 7 θ θ x FIGURE 3.. The top graph shows several training points in one dimension, known or assumed to

More information

Introduction to Machine Learning CMU-10701

Introduction to Machine Learning CMU-10701 Introduction to Machine Learning CMU-10701 Hidden Markov Models Barnabás Póczos & Aarti Singh Slides courtesy: Eric Xing i.i.d to sequential data So far we assumed independent, identically distributed

More information

Statistical Sequence Recognition and Training: An Introduction to HMMs

Statistical Sequence Recognition and Training: An Introduction to HMMs Statistical Sequence Recognition and Training: An Introduction to HMMs EECS 225D Nikki Mirghafori nikki@icsi.berkeley.edu March 7, 2005 Credit: many of the HMM slides have been borrowed and adapted, with

More information

Brief Introduction of Machine Learning Techniques for Content Analysis

Brief Introduction of Machine Learning Techniques for Content Analysis 1 Brief Introduction of Machine Learning Techniques for Content Analysis Wei-Ta Chu 2008/11/20 Outline 2 Overview Gaussian Mixture Model (GMM) Hidden Markov Model (HMM) Support Vector Machine (SVM) Overview

More information

An Introduction to Bioinformatics Algorithms Hidden Markov Models

An Introduction to Bioinformatics Algorithms  Hidden Markov Models Hidden Markov Models Hidden Markov Models Outline CG-islands The Fair Bet Casino Hidden Markov Model Decoding Algorithm Forward-Backward Algorithm Profile HMMs HMM Parameter Estimation Viterbi training

More information

MACHINE LEARNING INTRODUCTION: STRING CLASSIFICATION

MACHINE LEARNING INTRODUCTION: STRING CLASSIFICATION MACHINE LEARNING INTRODUCTION: STRING CLASSIFICATION THOMAS MAILUND Machine learning means different things to different people, and there is no general agreed upon core set of algorithms that must be

More information

Markov Chains and Hidden Markov Models. = stochastic, generative models

Markov Chains and Hidden Markov Models. = stochastic, generative models Markov Chains and Hidden Markov Models = stochastic, generative models (Drawing heavily from Durbin et al., Biological Sequence Analysis) BCH339N Systems Biology / Bioinformatics Spring 2016 Edward Marcotte,

More information

VL Algorithmen und Datenstrukturen für Bioinformatik ( ) WS15/2016 Woche 16

VL Algorithmen und Datenstrukturen für Bioinformatik ( ) WS15/2016 Woche 16 VL Algorithmen und Datenstrukturen für Bioinformatik (19400001) WS15/2016 Woche 16 Tim Conrad AG Medical Bioinformatics Institut für Mathematik & Informatik, Freie Universität Berlin Based on slides by

More information

Computational Genomics and Molecular Biology, Fall

Computational Genomics and Molecular Biology, Fall Computational Genomics and Molecular Biology, Fall 2011 1 HMM Lecture Notes Dannie Durand and Rose Hoberman October 11th 1 Hidden Markov Models In the last few lectures, we have focussed on three problems

More information

Statistical Methods for NLP

Statistical Methods for NLP Statistical Methods for NLP Sequence Models Joakim Nivre Uppsala University Department of Linguistics and Philology joakim.nivre@lingfil.uu.se Statistical Methods for NLP 1(21) Introduction Structured

More information

Speech Recognition Lecture 8: Expectation-Maximization Algorithm, Hidden Markov Models.

Speech Recognition Lecture 8: Expectation-Maximization Algorithm, Hidden Markov Models. Speech Recognition Lecture 8: Expectation-Maximization Algorithm, Hidden Markov Models. Mehryar Mohri Courant Institute and Google Research mohri@cims.nyu.com This Lecture Expectation-Maximization (EM)

More information

CS 7180: Behavioral Modeling and Decision- making in AI

CS 7180: Behavioral Modeling and Decision- making in AI CS 7180: Behavioral Modeling and Decision- making in AI Learning Probabilistic Graphical Models Prof. Amy Sliva October 31, 2012 Hidden Markov model Stochastic system represented by three matrices N =

More information

Lecture 3: ASR: HMMs, Forward, Viterbi

Lecture 3: ASR: HMMs, Forward, Viterbi Original slides by Dan Jurafsky CS 224S / LINGUIST 285 Spoken Language Processing Andrew Maas Stanford University Spring 2017 Lecture 3: ASR: HMMs, Forward, Viterbi Fun informative read on phonetics The

More information

Lecture 11: Hidden Markov Models

Lecture 11: Hidden Markov Models Lecture 11: Hidden Markov Models Cognitive Systems - Machine Learning Cognitive Systems, Applied Computer Science, Bamberg University slides by Dr. Philip Jackson Centre for Vision, Speech & Signal Processing

More information

Hidden Markov Models. x 1 x 2 x 3 x K

Hidden Markov Models. x 1 x 2 x 3 x K Hidden Markov Models 1 1 1 1 2 2 2 2 K K K K x 1 x 2 x 3 x K HiSeq X & NextSeq Viterbi, Forward, Backward VITERBI FORWARD BACKWARD Initialization: V 0 (0) = 1 V k (0) = 0, for all k > 0 Initialization:

More information

Natural Language Processing

Natural Language Processing SFU NatLangLab Natural Language Processing Anoop Sarkar anoopsarkar.github.io/nlp-class Simon Fraser University October 20, 2017 0 Natural Language Processing Anoop Sarkar anoopsarkar.github.io/nlp-class

More information

Data-Intensive Computing with MapReduce

Data-Intensive Computing with MapReduce Data-Intensive Computing with MapReduce Session 8: Sequence Labeling Jimmy Lin University of Maryland Thursday, March 14, 2013 This work is licensed under a Creative Commons Attribution-Noncommercial-Share

More information

Basic Text Analysis. Hidden Markov Models. Joakim Nivre. Uppsala University Department of Linguistics and Philology

Basic Text Analysis. Hidden Markov Models. Joakim Nivre. Uppsala University Department of Linguistics and Philology Basic Text Analysis Hidden Markov Models Joakim Nivre Uppsala University Department of Linguistics and Philology joakimnivre@lingfiluuse Basic Text Analysis 1(33) Hidden Markov Models Markov models are

More information

Basic math for biology

Basic math for biology Basic math for biology Lei Li Florida State University, Feb 6, 2002 The EM algorithm: setup Parametric models: {P θ }. Data: full data (Y, X); partial data Y. Missing data: X. Likelihood and maximum likelihood

More information

Natural Language Processing : Probabilistic Context Free Grammars. Updated 5/09

Natural Language Processing : Probabilistic Context Free Grammars. Updated 5/09 Natural Language Processing : Probabilistic Context Free Grammars Updated 5/09 Motivation N-gram models and HMM Tagging only allowed us to process sentences linearly. However, even simple sentences require

More information

Implementation of EM algorithm in HMM training. Jens Lagergren

Implementation of EM algorithm in HMM training. Jens Lagergren Implementation of EM algorithm in HMM training Jens Lagergren April 22, 2009 EM Algorithms: An expectation-maximization (EM) algorithm is used in statistics for finding maximum likelihood estimates of

More information

Stephen Scott.

Stephen Scott. 1 / 27 sscott@cse.unl.edu 2 / 27 Useful for modeling/making predictions on sequential data E.g., biological sequences, text, series of sounds/spoken words Will return to graphical models that are generative

More information

Lecture 7 Sequence analysis. Hidden Markov Models

Lecture 7 Sequence analysis. Hidden Markov Models Lecture 7 Sequence analysis. Hidden Markov Models Nicolas Lartillot may 2012 Nicolas Lartillot (Universite de Montréal) BIN6009 may 2012 1 / 60 1 Motivation 2 Examples of Hidden Markov models 3 Hidden

More information

Probabilistic Context-Free Grammars. Michael Collins, Columbia University

Probabilistic Context-Free Grammars. Michael Collins, Columbia University Probabilistic Context-Free Grammars Michael Collins, Columbia University Overview Probabilistic Context-Free Grammars (PCFGs) The CKY Algorithm for parsing with PCFGs A Probabilistic Context-Free Grammar

More information

Hidden Markov Models (HMMs)

Hidden Markov Models (HMMs) Hidden Markov Models (HMMs) Reading Assignments R. Duda, P. Hart, and D. Stork, Pattern Classification, John-Wiley, 2nd edition, 2001 (section 3.10, hard-copy). L. Rabiner, "A tutorial on HMMs and selected

More information

Hidden Markov Models for biological sequence analysis I

Hidden Markov Models for biological sequence analysis I Hidden Markov Models for biological sequence analysis I Master in Bioinformatics UPF 2014-2015 Eduardo Eyras Computational Genomics Pompeu Fabra University - ICREA Barcelona, Spain Example: CpG Islands

More information

Directed Probabilistic Graphical Models CMSC 678 UMBC

Directed Probabilistic Graphical Models CMSC 678 UMBC Directed Probabilistic Graphical Models CMSC 678 UMBC Announcement 1: Assignment 3 Due Wednesday April 11 th, 11:59 AM Any questions? Announcement 2: Progress Report on Project Due Monday April 16 th,

More information

Hidden Markov Models and Gaussian Mixture Models

Hidden Markov Models and Gaussian Mixture Models Hidden Markov Models and Gaussian Mixture Models Hiroshi Shimodaira and Steve Renals Automatic Speech Recognition ASR Lectures 4&5 23&27 January 2014 ASR Lectures 4&5 Hidden Markov Models and Gaussian

More information

Markov Chains and Hidden Markov Models

Markov Chains and Hidden Markov Models Chapter 1 Markov Chains and Hidden Markov Models In this chapter, we will introduce the concept of Markov chains, and show how Markov chains can be used to model signals using structures such as hidden

More information

11.3 Decoding Algorithm

11.3 Decoding Algorithm 11.3 Decoding Algorithm 393 For convenience, we have introduced π 0 and π n+1 as the fictitious initial and terminal states begin and end. This model defines the probability P(x π) for a given sequence

More information

Hidden Markov Models for biological sequence analysis

Hidden Markov Models for biological sequence analysis Hidden Markov Models for biological sequence analysis Master in Bioinformatics UPF 2017-2018 http://comprna.upf.edu/courses/master_agb/ Eduardo Eyras Computational Genomics Pompeu Fabra University - ICREA

More information

CS 136a Lecture 7 Speech Recognition Architecture: Training models with the Forward backward algorithm

CS 136a Lecture 7 Speech Recognition Architecture: Training models with the Forward backward algorithm + September13, 2016 Professor Meteer CS 136a Lecture 7 Speech Recognition Architecture: Training models with the Forward backward algorithm Thanks to Dan Jurafsky for these slides + ASR components n Feature

More information

Hidden Markov Models

Hidden Markov Models Hidden Markov Models Slides mostly from Mitch Marcus and Eric Fosler (with lots of modifications). Have you seen HMMs? Have you seen Kalman filters? Have you seen dynamic programming? HMMs are dynamic

More information

1. Markov models. 1.1 Markov-chain

1. Markov models. 1.1 Markov-chain 1. Markov models 1.1 Markov-chain Let X be a random variable X = (X 1,..., X t ) taking values in some set S = {s 1,..., s N }. The sequence is Markov chain if it has the following properties: 1. Limited

More information

Introduction to Machine Learning. Maximum Likelihood and Bayesian Inference. Lecturers: Eran Halperin, Lior Wolf

Introduction to Machine Learning. Maximum Likelihood and Bayesian Inference. Lecturers: Eran Halperin, Lior Wolf 1 Introduction to Machine Learning Maximum Likelihood and Bayesian Inference Lecturers: Eran Halperin, Lior Wolf 2014-15 We know that X ~ B(n,p), but we do not know p. We get a random sample from X, a

More information

Sequence Modelling with Features: Linear-Chain Conditional Random Fields. COMP-599 Oct 6, 2015

Sequence Modelling with Features: Linear-Chain Conditional Random Fields. COMP-599 Oct 6, 2015 Sequence Modelling with Features: Linear-Chain Conditional Random Fields COMP-599 Oct 6, 2015 Announcement A2 is out. Due Oct 20 at 1pm. 2 Outline Hidden Markov models: shortcomings Generative vs. discriminative

More information

Weighted Finite-State Transducers in Computational Biology

Weighted Finite-State Transducers in Computational Biology Weighted Finite-State Transducers in Computational Biology Mehryar Mohri Courant Institute of Mathematical Sciences mohri@cims.nyu.edu Joint work with Corinna Cortes (Google Research). 1 This Tutorial

More information

HIDDEN MARKOV MODELS

HIDDEN MARKOV MODELS HIDDEN MARKOV MODELS Outline CG-islands The Fair Bet Casino Hidden Markov Model Decoding Algorithm Forward-Backward Algorithm Profile HMMs HMM Parameter Estimation Viterbi training Baum-Welch algorithm

More information

Machine Learning & Data Mining Caltech CS/CNS/EE 155 Hidden Markov Models Last Updated: Feb 7th, 2017

Machine Learning & Data Mining Caltech CS/CNS/EE 155 Hidden Markov Models Last Updated: Feb 7th, 2017 1 Introduction Let x = (x 1,..., x M ) denote a sequence (e.g. a sequence of words), and let y = (y 1,..., y M ) denote a corresponding hidden sequence that we believe explains or influences x somehow

More information

A REVIEW AND APPLICATION OF HIDDEN MARKOV MODELS AND DOUBLE CHAIN MARKOV MODELS

A REVIEW AND APPLICATION OF HIDDEN MARKOV MODELS AND DOUBLE CHAIN MARKOV MODELS A REVIEW AND APPLICATION OF HIDDEN MARKOV MODELS AND DOUBLE CHAIN MARKOV MODELS Michael Ryan Hoff A Dissertation submitted to the Faculty of Science, University of the Witwatersrand, Johannesburg, in fulfilment

More information

CMSC 723: Computational Linguistics I Session #5 Hidden Markov Models. The ischool University of Maryland. Wednesday, September 30, 2009

CMSC 723: Computational Linguistics I Session #5 Hidden Markov Models. The ischool University of Maryland. Wednesday, September 30, 2009 CMSC 723: Computational Linguistics I Session #5 Hidden Markov Models Jimmy Lin The ischool University of Maryland Wednesday, September 30, 2009 Today s Agenda The great leap forward in NLP Hidden Markov

More information

Statistical Methods for NLP

Statistical Methods for NLP Statistical Methods for NLP Information Extraction, Hidden Markov Models Sameer Maskey Week 5, Oct 3, 2012 *many slides provided by Bhuvana Ramabhadran, Stanley Chen, Michael Picheny Speech Recognition

More information

10. Hidden Markov Models (HMM) for Speech Processing. (some slides taken from Glass and Zue course)

10. Hidden Markov Models (HMM) for Speech Processing. (some slides taken from Glass and Zue course) 10. Hidden Markov Models (HMM) for Speech Processing (some slides taken from Glass and Zue course) Definition of an HMM The HMM are powerful statistical methods to characterize the observed samples of

More information

Sequence labeling. Taking collective a set of interrelated instances x 1,, x T and jointly labeling them

Sequence labeling. Taking collective a set of interrelated instances x 1,, x T and jointly labeling them HMM, MEMM and CRF 40-957 Special opics in Artificial Intelligence: Probabilistic Graphical Models Sharif University of echnology Soleymani Spring 2014 Sequence labeling aking collective a set of interrelated

More information

Dept. of Linguistics, Indiana University Fall 2009

Dept. of Linguistics, Indiana University Fall 2009 1 / 14 Markov L645 Dept. of Linguistics, Indiana University Fall 2009 2 / 14 Markov (1) (review) Markov A Markov Model consists of: a finite set of statesω={s 1,...,s n }; an signal alphabetσ={σ 1,...,σ

More information

Today s Lecture: HMMs

Today s Lecture: HMMs Today s Lecture: HMMs Definitions Examples Probability calculations WDAG Dynamic programming algorithms: Forward Viterbi Parameter estimation Viterbi training 1 Hidden Markov Models Probability models

More information

order is number of previous outputs

order is number of previous outputs Markov Models Lecture : Markov and Hidden Markov Models PSfrag Use past replacements as state. Next output depends on previous output(s): y t = f[y t, y t,...] order is number of previous outputs y t y

More information

Outline. 1. Define likelihood 2. Interpretations of likelihoods 3. Likelihood plots 4. Maximum likelihood 5. Likelihood ratio benchmarks

Outline. 1. Define likelihood 2. Interpretations of likelihoods 3. Likelihood plots 4. Maximum likelihood 5. Likelihood ratio benchmarks This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike License. Your use of this material constitutes acceptance of that license and the conditions of use of materials on this

More information

Expectation-Maximization (EM) algorithm

Expectation-Maximization (EM) algorithm I529: Machine Learning in Bioinformatics (Spring 2017) Expectation-Maximization (EM) algorithm Yuzhen Ye School of Informatics and Computing Indiana University, Bloomington Spring 2017 Contents Introduce

More information

University of Cambridge. MPhil in Computer Speech Text & Internet Technology. Module: Speech Processing II. Lecture 2: Hidden Markov Models I

University of Cambridge. MPhil in Computer Speech Text & Internet Technology. Module: Speech Processing II. Lecture 2: Hidden Markov Models I University of Cambridge MPhil in Computer Speech Text & Internet Technology Module: Speech Processing II Lecture 2: Hidden Markov Models I o o o o o 1 2 3 4 T 1 b 2 () a 12 2 a 3 a 4 5 34 a 23 b () b ()

More information

Hidden Markov Models

Hidden Markov Models Hidden Markov Models Outline CG-islands The Fair Bet Casino Hidden Markov Model Decoding Algorithm Forward-Backward Algorithm Profile HMMs HMM Parameter Estimation Viterbi training Baum-Welch algorithm

More information

Expectation Maximisation (EM) CS 486/686: Introduction to Artificial Intelligence University of Waterloo

Expectation Maximisation (EM) CS 486/686: Introduction to Artificial Intelligence University of Waterloo Expectation Maximisation (EM) CS 486/686: Introduction to Artificial Intelligence University of Waterloo 1 Incomplete Data So far we have seen problems where - Values of all attributes are known - Learning

More information

SDS 321: Introduction to Probability and Statistics

SDS 321: Introduction to Probability and Statistics SDS 321: Introduction to Probability and Statistics Lecture 2: Conditional probability Purnamrita Sarkar Department of Statistics and Data Science The University of Texas at Austin www.cs.cmu.edu/ psarkar/teaching

More information

Quiz 1, COMS Name: Good luck! 4705 Quiz 1 page 1 of 7

Quiz 1, COMS Name: Good luck! 4705 Quiz 1 page 1 of 7 Quiz 1, COMS 4705 Name: 10 30 30 20 Good luck! 4705 Quiz 1 page 1 of 7 Part #1 (10 points) Question 1 (10 points) We define a PCFG where non-terminal symbols are {S,, B}, the terminal symbols are {a, b},

More information

CS838-1 Advanced NLP: Hidden Markov Models

CS838-1 Advanced NLP: Hidden Markov Models CS838-1 Advanced NLP: Hidden Markov Models Xiaojin Zhu 2007 Send comments to jerryzhu@cs.wisc.edu 1 Part of Speech Tagging Tag each word in a sentence with its part-of-speech, e.g., The/AT representative/nn

More information

Likelihood, MLE & EM for Gaussian Mixture Clustering. Nick Duffield Texas A&M University

Likelihood, MLE & EM for Gaussian Mixture Clustering. Nick Duffield Texas A&M University Likelihood, MLE & EM for Gaussian Mixture Clustering Nick Duffield Texas A&M University Probability vs. Likelihood Probability: predict unknown outcomes based on known parameters: P(x q) Likelihood: estimate

More information

STATS 306B: Unsupervised Learning Spring Lecture 5 April 14

STATS 306B: Unsupervised Learning Spring Lecture 5 April 14 STATS 306B: Unsupervised Learning Spring 2014 Lecture 5 April 14 Lecturer: Lester Mackey Scribe: Brian Do and Robin Jia 5.1 Discrete Hidden Markov Models 5.1.1 Recap In the last lecture, we introduced

More information

6.047/6.878/HST.507 Computational Biology: Genomes, Networks, Evolution. Lecture 05. Hidden Markov Models Part II

6.047/6.878/HST.507 Computational Biology: Genomes, Networks, Evolution. Lecture 05. Hidden Markov Models Part II 6.047/6.878/HST.507 Computational Biology: Genomes, Networks, Evolution Lecture 05 Hidden Markov Models Part II 1 2 Module 1: Aligning and modeling genomes Module 1: Computational foundations Dynamic programming:

More information

Collapsed Variational Bayesian Inference for Hidden Markov Models

Collapsed Variational Bayesian Inference for Hidden Markov Models Collapsed Variational Bayesian Inference for Hidden Markov Models Pengyu Wang, Phil Blunsom Department of Computer Science, University of Oxford International Conference on Artificial Intelligence and

More information

Hidden Markov Models

Hidden Markov Models Hidden Markov Models Lecture Notes Speech Communication 2, SS 2004 Erhard Rank/Franz Pernkopf Signal Processing and Speech Communication Laboratory Graz University of Technology Inffeldgasse 16c, A-8010

More information