I learn that the Viterbi algorithm used for Hidden Markov Model (HMM) can classify a sequence of hidden states from the corresponding observations; Markov Random Field (MRF) and Conditional Random Field (CRF) can also do it.

Can these algorithms be used to classify a single future state?


Yes this is possible and is exactly what a Markov process aims to accomplish.

The Hidden Markov Model can be considered a simple dynamic Bayesian network. This means that it will generate a probabilistic outcome for a number of states (classes) given a sequence of inputs.

This can be used for a classification task based on a threshold probability to make a confirmed decision.

Let's take a simple example


The above example is a model to determine how a person will be feeling given some sample data of the previous days.

# Sample data
data = ['Healthy', 'Healthy', 'Fever']

Using this data, it's possible to calculate the probability of each possible state (outcome).

# Probability after 2 Healthy and 1 Fever day
P = 0.6 * 0.7 * 0.3

# Final day state 'Fever'
# Calculating probabilities for each state
Dizzy  = P * 0.6
Cold   = P * 0.3
Normal = P * 0.1

We can calculate the probability of each state and this will be unique for every unique sequence of historical data.

  • $\begingroup$ Do you have example code? $\endgroup$
    – drerD
    Jun 19 '19 at 18:44
  • $\begingroup$ Code for this example? Or in general? The issue is that HMMs are not easy to generate. The probabilities, specified in the example are dummies, in a real use case, those values will have to be computed statistically from a large dataset before the model can be used. $\endgroup$ Jun 19 '19 at 21:05
  • $\begingroup$ code in general is fine. I’ve tried a python package, but I can only do decoding to get a sequence of states, while I want to get the state of a single input. $\endgroup$
    – drerD
    Jun 20 '19 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.