Baum–Welch algorithm explained

In electrical engineering, statistical computing and bioinformatics, the Baum–Welch algorithm is a special case of the expectation–maximization algorithm used to find the unknown parameters of a hidden Markov model (HMM). It makes use of the forward-backward algorithm to compute the statistics for the expectation step.

History

The Baum–Welch algorithm was named after its inventors Leonard E. Baum and Lloyd R. Welch. The algorithm and the Hidden Markov models were first described in a series of articles by Baum and his peers at the IDA Center for Communications Research, Princeton in the late 1960s and early 1970s.[1] One of the first major applications of HMMs was to the field of speech processing.[2] In the 1980s, HMMs were emerging as a useful tool in the analysis of biological systems and information, and in particular genetic information.[3] They have since become an important tool in the probabilistic modeling of genomic sequences.[4]

Description

A hidden Markov model describes the joint probability of a collection of "hidden" and observed discrete random variables. It relies on the assumption that the i-th hidden variable given the (i − 1)-th hidden variable is independent of previous hidden variables, and the current observation variables depend only on the current hidden state.

The Baum–Welch algorithm uses the well known EM algorithm to find the maximum likelihood estimate of the parameters of a hidden Markov model given a set of observed feature vectors.

Let

Xt

be a discrete hidden random variable with

N

possible values (i.e. We assume there are

N

states in total). We assume the

P(Xt\midXt-1)

is independent of time

t

, which leads to the definition of the time-independent stochastic transition matrix

A=\{aij\}=P(Xt=j\midXt-1=i).

The initial state distribution (i.e. when

t=1

) is given by

\pii=P(X1=i).

The observation variables

Yt

can take one of

K

possible values. We also assume the observation given the "hidden" state is time independent. The probability of a certain observation

yi

at time

t

for state

Xt=j

is given by

bj(yi)=P(Yt=yi\midXt=j).

Taking into account all the possible values of

Yt

and

Xt

, we obtain the

N x K

matrix

B=\{bj(yi)\}

where

bj

belongs to all the possible states and

yi

belongs to all the observations.

An observation sequence is given by

Y=(Y1=y1,Y2=y2,\ldots,YT=yT)

.

Thus we can describe a hidden Markov chain by

\theta=(A,B,\pi)

. The Baum–Welch algorithm finds a local maximum for

\theta*=\operatorname{argmax}\thetaP(Y\mid\theta)

(i.e. the HMM parameters

\theta

that maximize the probability of the observation).[5]

Algorithm

Set

\theta=(A,B,\pi)

with random initial conditions. They can also be set using prior information about the parameters if it is available; this can speed up the algorithm and also steer it toward the desired local maximum.

Forward procedure

Let

\alphai(t)=P(Y1=y1,\ldots,Yt=yt,Xt=i\mid\theta)

, the probability of seeing the observations

y1,y2,\ldots,yt

and being in state

i

at time

t

. This is found recursively:

\alphai(1)=\piibi(y1),

\alphai(t+1)=bi(yt+1)

N
\sum
j=1

\alphaj(t)aji.

Since this series converges exponentially to zero, the algorithm will numerically underflow for longer sequences.[6] However, this can be avoided in a slightly modified algorithm by scaling

\alpha

in the forward and

\beta

in the backward procedure below.

Backward procedure

Let

\betai(t)=P(Yt+1=yt+1,\ldots,YT=yT\midXt=i,\theta)

that is the probability of the ending partial sequence

yt+1,\ldots,yT

given starting state

i

at time

t

. We calculate

\betai(t)

as,

\betai(T)=1,

\betai(t)=\sum

N
j=1

\betaj(t+1)aijbj(yt+1).

Update

We can now calculate the temporary variables, according to Bayes' theorem:

\gammai(t)=P(Xt=i\midY,\theta)=

P(Xt=i,Y\mid\theta)
P(Y\mid\theta)

=

\alphai(t)\betai(t)
N
\sum\alphaj(t)\betaj(t)
j=1

,

which is the probability of being in state

i

at time

t

given the observed sequence

Y

and the parameters

\theta

\xiij(t)=P(Xt=i,Xt+1=j\midY,\theta)=

P(Xt=i,Xt+1=j,Y\mid\theta)
P(Y\mid\theta)

=

\alphai(t)aij\betaj(t+1)bj(yt+1)
N
\sum
N
\sum
w=1
\alphak(t)akw\betaw(t+1)bw(yt+1)
k=1

,

which is the probability of being in state

i

and

j

at times

t

and

t+1

respectively given the observed sequence

Y

and parameters

\theta

.

The denominators of

\gammai(t)

and

\xiij(t)

are the same ; they represent the probability of making the observation

Y

given the parameters

\theta

.

The parameters of the hidden Markov model

\theta

can now be updated:
*
\pi
i

=\gammai(1),

which is the expected frequency spent in state

i

at time

1

.
*=
T-1
\sum\xiij(t)
t=1
T-1
\sum\gammai(t)
t=1
a
ij

,

which is the expected number of transitions from state i to state j compared to the expected total number of transitions away from state i. To clarify, the number of transitions away from state i does not mean transitions to a different state j, but to any state including itself. This is equivalent to the number of times state i is observed in the sequence from t = 1 to t = T − 1.
*(v
b
k)=
T
\sum
1
yt=vk
\gammai(t)
t=1
T
\sum\gammai(t)
t=1

,

where
1
yt=vk

= \begin{cases} 1&ifyt=vk,\\ 0&otherwise \end{cases}

is an indicator function, and
*(v
b
k)
is the expected number of times the output observations have been equal to

vk

while in state

i

over the expected total number of times in state

i

.

These steps are now repeated iteratively until a desired level of convergence.

Note: It is possible to over-fit a particular data set. That is,

P(Y\mid\thetafinal)>P(Y\mid\thetatrue)

. The algorithm also does not guarantee a global maximum.

Multiple sequences

The algorithm described thus far assumes a single observed sequence

Y=y1,\ldots,yN

. However, in many situations, there are several sequences observed:

Y1,\ldots,YR

. In this case, the information from all of the observed sequences must be used in the update of the parameters

A

,

\pi

, and

b

. Assuming that you have computed

\gammair(t)

and

\xiijr(t)

for each sequence

y1,r

,\ldots,y
Nr,r
, the parameters can now be updated:
*
\pi
i

=

R
\sum\gammair(1)
r=1
R
*=
R
\sum
T-1
\sum
t=1
\xiijr(t)
r=1
R
\sum
T-1
\sum
t=1
\gammair(t)
r=1
a
ij

,

*(v
b
k)=
R
\sum
T
\sum
t=1
1
ytr=vk
\gammair(t)
r=1
R
\sum
T
\sum
t=1
\gammair(t)
r=1

,

where
1
ytr=vk

= \begin{cases} 1&ifyt,r=vk,\\ 0&otherwise \end{cases}

is an indicator function

Example

Suppose we have a chicken from which we collect eggs at noon every day. Now whether or not the chicken has laid eggs for collection depends on some unknown factors that are hidden. We can however (for simplicity) assume that the chicken is always in one of two states that influence whether the chicken lays eggs, and that this state only depends on the state on the previous day. Now we don't know the state at the initial starting point, we don't know the transition probabilities between the two states and we don't know the probability that the chicken lays an egg given a particular state.[7] [8] To start we first guess the transition and emission matrices.

Transition
State 1 State 2
State 10.5 0.5
State 20.3 0.7
Emission
No Eggs Eggs
State 10.3 0.7
State 20.8 0.2
Initial
State 10.2
State 20.8
We then take a set of observations (E = eggs, N = no eggs): N, N, N, N, N, E, E, N, N, N

This gives us a set of observed transitions between days: NN, NN, NN, NN, NE, EE, EN, NN, NN

The next step is to estimate a new transition matrix. For example, the probability of the sequence NN and the state being then is given by the following,

P(S1)P(N|S1)P(S1S2)P(N|S2).

Observed sequence Highest probability of observing that sequence if state is then Highest Probability of observing that sequence
NN 0.024 = 0.2 × 0.3 × 0.5 × 0.8 0.3584 ,
NN 0.024 = 0.2 × 0.3 × 0.5 × 0.8 0.3584 ,
NN 0.024 = 0.2 × 0.3 × 0.5 × 0.8 0.3584 ,
NN 0.024 = 0.2 × 0.3 × 0.5 × 0.8 0.3584 ,
NE 0.006 = 0.2 × 0.3 × 0.5 × 0.2 0.1344 ,
EE 0.014 = 0.2 × 0.7 × 0.5 × 0.2 0.0490 ,
EN 0.056 = 0.2 × 0.7 × 0.5 × 0.8 0.0896 ,
NN 0.024 = 0.2 × 0.3 × 0.5 × 0.8 0.3584 ,
NN 0.024 = 0.2 × 0.3 × 0.5 × 0.8 0.3584 ,
Total0.22 2.4234

Thus the new estimate for the to transition is now

0.22
2.4234

=0.0908

(referred to as "Pseudo probabilities" in the following tables). We then calculate the to, to and to transition probabilities and normalize so they add to 1. This gives us the updated transition matrix:
Old Transition Matrix
State 1 State 2
State 10.5 0.5
State 20.3 0.7
New Transition Matrix (Pseudo Probabilities)
State 1 State 2
State 10.0598 0.0908
State 20.2179 0.9705
New Transition Matrix (After Normalization)
State 1 State 2
State 10.3973 0.6027
State 20.1833 0.8167

Next, we want to estimate a new emission matrix,

Observed Sequence Highest probability of observing that sequence
if E is assumed to come from
Highest Probability of observing that sequence
NE 0.1344 , 0.1344 ,
EE 0.0490 , 0.0490 ,
EN 0.0560 , 0.0896 ,
Total0.2394 0.2730

The new estimate for the E coming from emission is now

0.2394
0.2730

=0.8769

.

This allows us to calculate the emission matrix as described above in the algorithm, by adding up the probabilities for the respective observed sequences. We then repeat for if N came from and for if N and E came from and normalize.

Old Emission Matrix
No Eggs Eggs
State 10.3 0.7
State 20.8 0.2
New Emission Matrix (Estimates)
No Eggs Eggs
State 10.0404 0.8769
State 21.0000 0.7385
New Emission Matrix (After Normalization)
No Eggs Eggs
State 10.0441 0.9559
State 20.5752 0.4248

To estimate the initial probabilities we assume all sequences start with the hidden state and calculate the highest probability and then repeat for . Again we then normalize to give an updated initial vector.

Finally we repeat these steps until the resulting probabilities converge satisfactorily.

Applications

Speech recognition

Hidden Markov Models were first applied to speech recognition by James K. Baker in 1975.[9] Continuous speech recognition occurs by the following steps, modeled by a HMM. Feature analysis is first undertaken on temporal and/or spectral features of the speech signal. This produces an observation vector. The feature is then compared to all sequences of the speech recognition units. These units could be phonemes, syllables, or whole-word units. A lexicon decoding system is applied to constrain the paths investigated, so only words in the system's lexicon (word dictionary) are investigated. Similar to the lexicon decoding, the system path is further constrained by the rules of grammar and syntax. Finally, semantic analysis is applied and the system outputs the recognized utterance. A limitation of many HMM applications to speech recognition is that the current state only depends on the state at the previous time-step, which is unrealistic for speech as dependencies are often several time-steps in duration.[10] The Baum–Welch algorithm also has extensive applications in solving HMMs used in the field of speech synthesis.[11]

Cryptanalysis

The Baum–Welch algorithm is often used to estimate the parameters of HMMs in deciphering hidden or noisy information and consequently is often used in cryptanalysis. In data security an observer would like to extract information from a data stream without knowing all the parameters of the transmission. This can involve reverse engineering a channel encoder.[12] HMMs and as a consequence the Baum–Welch algorithm have also been used to identify spoken phrases in encrypted VoIP calls.[13] In addition HMM cryptanalysis is an important tool for automated investigations of cache-timing data. It allows for the automatic discovery of critical algorithm state, for example key values.[14]

Applications in bioinformatics

Finding genes

Prokaryotic

The GLIMMER (Gene Locator and Interpolated Markov ModelER) software was an early gene-finding program used for the identification of coding regions in prokaryotic DNA.[15] [16] GLIMMER uses Interpolated Markov Models (IMMs) to identify the coding regions and distinguish them from the noncoding DNA. The latest release (GLIMMER3) has been shown to have increased specificity and accuracy compared with its predecessors with regard to predicting translation initiation sites, demonstrating an average 99% accuracy in locating 3' locations compared to confirmed genes in prokaryotes.[17]

Eukaryotic

The GENSCAN webserver is a gene locator capable of analyzing eukaryotic sequences up to one million base-pairs (1 Mbp) long.[18] GENSCAN utilizes a general inhomogeneous, three periodic, fifth order Markov model of DNA coding regions. Additionally, this model accounts for differences in gene density and structure (such as intron lengths) that occur in different isochores. While most integrated gene-finding software (at the time of GENSCANs release) assumed input sequences contained exactly one gene, GENSCAN solves a general case where partial, complete, or multiple genes (or even no gene at all) is present.[19] GENSCAN was shown to exactly predict exon location with 90% accuracy with 80% specificity compared to an annotated database.[20]

Copy-number variation detection

Copy-number variations (CNVs) are an abundant form of genome structure variation in humans. A discrete-valued bivariate HMM (dbHMM) was used assigning chromosomal regions to seven distinct states: unaffected regions, deletions, duplications and four transition states. Solving this model using Baum-Welch demonstrated the ability to predict the location of CNV breakpoint to approximately 300 bp from micro-array experiments.[21] This magnitude of resolution enables more precise correlations between different CNVs and across populations than previously possible, allowing the study of CNV population frequencies. It also demonstrated a direct inheritance pattern for a particular CNV.

Implementations

See also

External links

Notes and References

  1. Web site: Rabiner . Lawrence . First Hand: The Hidden Markov Model . IEEE Global History Network . 2 October 2013 .
  2. Jelinek . Frederick . Bahl . Lalit R. . Mercer . Robert L. . Design of a linguistic statistical decoder for the recognition of continuous speech . IEEE Transactions on Information Theory . May 1975 . 21 . 3 . 250–6 . 10.1109/tit.1975.1055384 .
  3. Bishop . Martin J. . Thompson . Elizabeth A. . Maximum likelihood alignment of DNA sequences . Journal of Molecular Biology . 20 July 1986 . 190 . 2 . 159–65 . 10.1016/0022-2836(86)90289-5 . 3641921 .
  4. Book: Durbin, Richard . Biological Sequence Analysis: Probabilistic Models of Proteins and Nucleic Acids . 23 April 1998 . Cambridge University Press . 978-0-521-62041-3 .
  5. Book: Bilmes, Jeff A. . A Gentle Tutorial of the EM Algorithm and its Application to Parameter Estimation for Gaussian Mixture and Hidden Markov Models . 1998 . International Computer Science Institute . Berkeley, CA . 7–13 .
  6. Web site: A Tutorial on Hidden Markov Models and Selected Applications in Speech recognition. Rabiner. Lawrence. February 1989. Proceedings of the IEEE. 29 November 2019.
  7. Web site: Baum-Welch and HMM applications . Johns Hopkins Bloomberg School of Public Health . https://web.archive.org/web/20210414224816/http://www.biostat.jhsph.edu/bstcourse/bio638/notes/HMMs_BaumWelch.pdf . 11 October 2019 . 2021-04-14 .
  8. Web site: Frazzoli . Emilio . Intro to Hidden Markov Models: the Baum-Welch Algorithm . Aeronautics and Astronautics, Massachusetts Institute of Technology . 2 October 2013 .
  9. Baker . James K. . James K. Baker . 10.1109/TASSP.1975.1162650 . The DRAGON system—An overview . IEEE Transactions on Acoustics, Speech, and Signal Processing . 23 . 24–29 . 1975 .
  10. Rabiner . Lawrence . A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition . Proceedings of the IEEE . February 1989 . 77 . 2 . 257–286 . 10.1109/5.18626 . 10.1.1.381.3454 . 13618539 .
  11. Tokuda . Keiichi . Takayoshi . Yoshimura . Takashi . Masuko . Takao . Kobayashi . Tadashi . Kitamura . Speech Parameter Generation Algorithms for HMM-Based Speech Synthesis . IEEE International Conference on Acoustics, Speech, and Signal Processing . 2000 . 3 .
  12. Dingel . Janis . Joachim . Hagenauer . Parameter Estimation of a Convolutional Encoder from Noisy Observations . IEEE International Symposium on Information Theory . 24 June 2007 .
  13. Wright . Charles . Lucas . Ballard . Scott . Coull . Fabian . Monrose . Gerald . Masson . Spot me if you can: Uncovering spoken phrases in encrypted VoIP conversations . IEEE International Symposium on Security and Privacy . 2008 .
  14. Book: Brumley . Bob . Risto . Hakala . Advances in Cryptology – ASIACRYPT 2009 . Cache-Timing Template Attacks . 2009 . 5912 . 667–684 . 10.1007/978-3-642-10366-7_39 . Lecture Notes in Computer Science . 978-3-642-10365-0 .
  15. Salzberg . Steven . Arthur L. . Delcher . Simon . Kasif . Owen . White . Microbial gene identification using interpolated Markov Models . Nucleic Acids Research . 1998 . 26 . 2 . 544–548 . 10.1093/nar/26.2.544 . 9421513 . 147303 .
  16. Web site: Glimmer: Microbial Gene-Finding System . Johns Hopkins University - Center for Computational Biology .
  17. Delcher . Arthur . Kirsten A. . Bratke . Edwin C. . Powers . Steven L. . Salzberg . Identifying bacterial genes and endosymbiont DNA with Glimmer . Bioinformatics . 2007 . 23 . 6 . 673–679 . 10.1093/bioinformatics/btm009 . 17237039 . 2387122 .
  18. Web site: Burge . Christopher . The GENSCAN Web Server at MIT . 2 October 2013 . https://web.archive.org/web/20130906115338/http://genes.mit.edu/GENSCAN.html . 6 September 2013 . dead .
  19. Burge . Chris . Samuel . Karlin . Prediction of Complete Gene Structures in Human Genomic DNA . Journal of Molecular Biology . 1997 . 268 . 78–94 . 10.1006/jmbi.1997.0951 . 9149143 . 1 . 10.1.1.115.3107 .
  20. Burge . Christopher . Samuel . Karlin . Finding the Genes in Genomic DNA . Current Opinion in Structural Biology . 1998 . 8 . 3 . 346–354 . 10.1016/s0959-440x(98)80069-9 . 9666331 . free .
  21. Korbel . Jan . Jan O. Korbel . Alexander . Urban . Fabien . Grubert . Jiang . Du . Thomas . Royce . Peter . Starr . Guoneng . Zhong . Beverly . Emanuel . Sherman . Weissman . Michael . Snyder . Marg . Gerstein . Systematic prediction and validation of breakpoints associated with copy-number variations in the human genome . Proceedings of the National Academy of Sciences of the United States of America . 12 June 2007 . 104 . 24 . 10110–5 . 10.1073/pnas.0703834104 . 17551006 . 1891248 . 2007PNAS..10410110K . free .