Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

This is a time series task, there's no reason to believe HMMs would work here.

I'd suggest you look at time series methods---there's a family of methods called ARIMA which should work nicely.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top