Reader small image

You're reading from  Hands-On Markov Models with Python

Product typeBook
Published inSep 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788625449
Edition1st Edition
Languages
Concepts
Right arrow
Authors (2):
Ankur Ankan
Ankur Ankan
author image
Ankur Ankan

Ankur Ankan is a BTech graduate from IIT (BHU), Varanasi. He is currently working in the field of data science. He is an open source enthusiast and his major work includes starting pgmpy with four other members. In his free time, he likes to participate in Kaggle competitions.
Read more about Ankur Ankan

Abinash Panda
Abinash Panda
author image
Abinash Panda

Abinash Panda has been a data scientist for more than 4 years. He has worked at multiple early-stage start-ups and helped them build their data analytics pipelines. He loves to munge, plot, and analyze data. He has been a speaker at Python conferences. These days, he is busy co-founding a start-up. He has contributed to books on probabilistic graphical models by Packt Publishing.
Read more about Abinash Panda

View More author details
Right arrow

Parameter Learning Using Maximum Likelihood

In the previous chapter, we discussed the state inference in the case of a Hidden Markov Model (HMM). We tried to predict the next state for an HMM using the information of previous state transitions. But in each cases, we had assumed that we already knew the transition and emission probabilities of the model. But in real-life problems, we usually need to learn these parameters from our observations.

In this chapter, we will try to estimate the parameters of our HMM model through data gathered from observations. We will be covering the following topics:

  • Maximum likelihood learning, with examples
  • Maximum likelihood learning in HMMs
  • Expectation maximization algorithms
  • The Baum-Welch algorithm

Maximum likelihood learning

Before diving into learning about maximum likelihood estimation (MLE) in HMMs, let's try to understand the basic concepts of MLE in generic cases. As the name suggests, MLE tries to select the parameters of the model that maximizes the likelihood of observed data. The likelihood for any model with given parameters is defined as the probability of getting the observed data, and can be written as follows:

Here, D={D1, D2, D3, …, Dn} is the observed data, and θ is the set of parameters governing our model. In most cases, for simplicity, we assume that the datapoints are independent and identically distributed (IID). With that assumption, we can simplify the definition of our likelihood function as follows:

Here, we have used the multiplication rule for independent random variables to decompose the joint distribution into product...

MLE for HMMs

Having a basic understanding of MLE, we can now move on to applying these concepts to the case of HMMs. In the next few subsections, we will see two possible scenarios of learning in HMMs, namely, supervised learning and unsupervised learning.

Supervised learning

In the case of supervised learning, we use the data generated by sampling the process that we are trying to model. If we are trying to parameterize our HMM model using simple discrete distributions, we can simply apply the MLE to compute the transition and emission distributions by counting the number of transitions from any given state to another state. Similarly, we can compute the emission distribution by counting the output states from different hidden...

Summary

In this chapter, we introduced algorithms for doing parameter estimation of a given HMM model. We started by looking into the basics of MLE and then applied the concepts to HMMs. For HMM training, we looked into two different scenarios: supervised training, when we have the observations for the hidden states, and unsupervised training, when we only have the output observations.

We also talked about the problems with estimation using MLE. In the next chapter, we will introduce algorithms for doing parameter estimation using the Bayesian approach, which tries to solve these issues.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Markov Models with Python
Published in: Sep 2018Publisher: PacktISBN-13: 9781788625449
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Ankur Ankan

Ankur Ankan is a BTech graduate from IIT (BHU), Varanasi. He is currently working in the field of data science. He is an open source enthusiast and his major work includes starting pgmpy with four other members. In his free time, he likes to participate in Kaggle competitions.
Read more about Ankur Ankan

author image
Abinash Panda

Abinash Panda has been a data scientist for more than 4 years. He has worked at multiple early-stage start-ups and helped them build their data analytics pipelines. He loves to munge, plot, and analyze data. He has been a speaker at Python conferences. These days, he is busy co-founding a start-up. He has contributed to books on probabilistic graphical models by Packt Publishing.
Read more about Abinash Panda