0
$\begingroup$

I have some time-series data, which I need to use to predict a binary label for a given time-stamp. I was initially doing it using a Logistic Regression Model but I later figured that a time-series based problem could be better solved using Hidden Markov Models. I might also save on time since this prediction is to be made for ~200,000 time-stamps.

I have been able to obtain the next n hidden states using the hmmlearn implementation, but what I really need are 0/1 labels.

How can I (if possible) use HMM as a binary classifier?

$\endgroup$
2
$\begingroup$

I have no experience in hmmlearn.

But if you want to receive the labels for the underlying states of the process you have to do 'decoding' by using the 'Viterbi' algorithm. It calculates the most probable state sequence for your data. So if you only have two hidden states it calculates a 0/1 label for each of your time-stamps.

If instead you're trying to discern between two different processes and recognize them, you have to train two different HMMs for the two processes and calculate the foward probabilty up to time t. Then you can choose the process with the higher probability.

| improve this answer | |
$\endgroup$
0
$\begingroup$

Actually, for binary classification with HMMs you have 2 choices:

  • Either you have many examples for both Class A and B. Then you can train one HMM from your samples of Class A and one from your samples from Class B. When you want to classify a new sample, you compute the likelihood of this sample with respect to the 2 HMMs and choose the one with the highest likelihood.

  • In the case one label is way more frequent than the other (say Class B appears for every 100 samples of Class A), or in the case one category is broader than the other (have more variance, i.e. Class A is an expected behavior of a process and Class B is all the cases that are abnormal), then we might want to train a unique HMM for Class A. For each new sample, we compute the likelihood to the model, and if it falls below a pre-defined threshold (that can be chosen with respect to some validation sample, or in the worst case, from the training samples themselves) we assign this sample to Class B. If the likelihood is above the threshold, we assign the sample to Class A.

| improve this answer | |
$\endgroup$

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.