mattjj / pyhsmm

MIT License
545 stars 172 forks source link

Question #72

Closed jmgo closed 7 years ago

jmgo commented 7 years ago

Hi!

Is it possible to use distributions for duration (HSMM) when using the viterbi method? In my case I just set the HMM model (intial, observational and transitional models) and then use the Viterbi algorithm (see the code below). I do not use any optimization because I am operating in a supervised setting.

hmm = HMM(trans_matrix=trans_matrix,  obs_distns=obs_distns, pi_0 = pi_0)
output_seq = hmm.heldout_viterbi(data) 

Best regards, jmgo

mattjj commented 7 years ago

Yes, just create an HSMM instance instead (passing dur_distns to the constructor) and the same thing should work. (The Viterbi methods are inherited from the HMM parent classes, which is hard to see with the mixin style the code is written in.) This method ultimately gets called, which calls this HSMM Viterbi function. It looks like we don't have low-level code for HSMM Viterbi.

Let me know if anything in that process breaks and we'll fix it (eventually)!

jmgo commented 7 years ago

Thank you very much for the answer!

Ok, if any error pops out I'll inform you.

Regards, jmgo