Using HIdden Markov Model for prediction

maheshakya picture maheshakya · Sep 28, 2013 · Viewed 12k times · Source

Suppose there is a sequence of observations,e.g. [1,2,3,5,5,5,2,3,2,3, ..., 3, 4]. I am trying to use the current implementation of HMM in Scikit-learn to predict the next value of this observation sequence. I have 2 questions regarding this.

  1. Given a sequence of observations, how do I predict the next observation(as mentioned above)?

  2. Given many sequences of n observations and n+1 observations of those sequences, can HMM be used to predict the (n+1)th observation of a new sequence of n observations? If so how?

I couldn't grasp much about this from the documentation.

I found a likely duplicate, but it doesn't specify on how to use HMM in Scikit-learn to predict the next value in a sequence.

Answer

Fred Foo picture Fred Foo · Sep 29, 2013

HMMs are not a good fit for this problem. They're good at for predicting the labels (hidden states) of a fully observed sequence, not for completing a sequence. Try training a classifier or regression model on windows of observations, then use that for prediction. I.e. at training time give the model observations (i, ..., i + k) as features and observation i + k + 1 as the target, for all positions i in each of your given sequences. At test time, feed the last k observations as features.