1

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?

Borhan Kazimipour
  • 866
  • 1
  • 10
  • 20
drerD
  • 298
  • 2
  • 6

1 Answers1

0

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

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.

skillsmuggler
  • 393
  • 2
  • 11
  • Do you have example code? – drerD Jun 19 '19 at 18:44
  • 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. – skillsmuggler Jun 19 '19 at 21:05
  • 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. – drerD Jun 20 '19 at 00:21