# How to Train HMM model with two different sequences using the Baum-Wech algorithm

I am using HMM to visualize drinking gestures of different container types.

I began training HMM with one sequence corresponding to one container type, but I want to visualize it with python now with different container types.

How can I map different sequences in one model?

For the training data do I have to insert them as one sequence (of different container types)?

• "I began training HMM with one sequence" - This is clearly not a good idea. Your HMM will suffer from overfitting... You need more than 1 sequence to train a model. So your last guess is right! However, if you know the containers you are studying, the best way of doing thing might be to train one HMM for each container type. HMMs is my field of research, I can write a more complete answer later today. Commented Dec 19, 2016 at 15:02
• Thank you so much for your reply. Actually after posting I have tried to make one model (and of course add transitions) for drinking in two different containers. I have tried a topology which I am not sure whether it is the suitable one or not. Then I have trained my model for two training data (for drinking in two containers)(two times model.train()) but after that I don't know how I can evaluate my top level model. Commented Dec 19, 2016 at 15:46

• Train one HMM for each type of container. Depending of the nature of your sequences samples (discrete? continuous values?) use either discrete emission probabilities or Gaussian ones. If your sequences always start from the "same moment" in the action of drinking, using a left-to-right topology could be appropriate (for this, you often just need to initialize the transition matrix as an upper-triangular matrix). With Python, there is the hmmlearn library that provides you with the functions needed to train an HMM in all the aforementioned cases (discrete, Gaussian, left-to-right). Here's the doc. (The documentation also explains how to handle multiple training samples.)