pythonhidden-markov-modelshmmlearn

How to fit multiple HMMs in a single dataset using Python?


I am trying to fit HMMs in my dataset for modelling purposes. Using the hmm.GaussianHMM function of hmmlearn, I have fit a single HMM with 2-5 hidden states. My code looks like this:

HMMmodel = hmm.GaussianHMM(n_components=2, covariance_type="full", n_iter=2)
HMMmodel.fit(Sdata)

The above code is a GaussianHMM for 2 hidden states.

Now, if I want to fit another HMM in the same data alongside the existing HMM, how should I do it? So, I want to have two HMMs for my dataset with 2-5 hidden states for each HMM. Any resource or hints in this regard will be really useful.


Solution

  • HMMmodel = hmm.GaussianHMM(n_components=2, covariance_type="full", n_iter=2)
    HMMmodel.fit(Sdata)
    
    HMMmodel2 = hmm.GaussianHMM(n_components=2, covariance_type="full", n_iter=2)
    HMMmodel2.fit(Sdata)