jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.29k stars 591 forks source link

GMM-HMM predictions shows only "Sequence is impossible." #992

Closed teoML closed 1 year ago

teoML commented 1 year ago

Hi! I tried implementing an HMM with General Mixture Model (which takes Multivariate Gaussians), but for some reasons it is not working properly and it shows every time the warning "Sequence is impossible." when I try to do prediction. What I did is in a nutshell the following: I trained a separate GMM for each state (class) in my observation data (one GMM per class with several components). After that I initialized the HMM model manually by using the GMM as distribution, I added some manually defined transition probabilities and baked the model to set the architecture. The last step was the labeled training, where I used fit() on the training data. The training seems to work well, however when I do prediction I always get the warning that the sequence is impossible... What am I doing wrong?

The whole code can be run here: https://colab.research.google.com/drive/1LYD2yzLiRdmHOJQ77lc2LH6J33wlgPYh?usp=sharing

Update: @jmschrei I noticed that after performing fit() on the baked model, the HMM has 2 start-states and 2 end-states. Could this also cause the problem?

Thank you!

tobiasweede commented 1 year ago

Thank you for sharing your code!

You need to add a start point to make it work: https://colab.research.google.com/drive/1Js2Lbcb97vpPz2AwCd0KTO8m5rouWrLK?usp=sharing

image