0

I am using the HMMlearn module to generate a HMM with a Gaussian Mixture Model.

The problem is I want to initialize the mean, variance and weight of each mixture component before I fit the model to any data.

How would I go about doing this?

Dider
  • 367
  • 1
  • 3
  • 17

1 Answers1

2

From the HHMlean documentation

Each HMM parameter has a character code which can be used to customize its initialization and estimation. EM algorithm needs a starting point to proceed, thus prior to training each parameter is assigned a value either random or computed from the data. It is possible to hook into this process and provide a starting point explicitly. To do so

  1. ensure that the character code for the parameter is missing from init_params and then
  2. set the parameter to the desired value.

Here is an example:

model = hmm.GaussianHMM(n_components=3, n_iter=100, init_params="t")
model.startprob_ = np.array([0.6, 0.3, 0.1])
model.means_ = np.array([[0.0, 0.0], [3.0, -3.0], [5.0, 10.0]])
model.covars_ = np.tile(np.identity(2), (3, 1, 1))

Another example for initializing a GMMHMM

model = hmm.GMMHMM(n_components=3, n_iter=100, init_params="smt")
model.gmms_ = [sklearn.mixture.GMM(),sklearn.mixture.GMM(),sklearn.mixture.GMM()]

The GMMs themselves can be initialised in a very similar way using its attributes and by providing in the init_params string, which attributes should be initialize by the constructor.

sietschie
  • 7,425
  • 3
  • 33
  • 54
  • Wait, this is for a standard Gaussian HMM not a mixture (which is GMMHMM). What are the attribute names for the mixture? Particularly weight and variance? – Dider May 01 '16 at 18:49
  • you mean the [`gmms_` attribute](http://hmmlearn.readthedocs.io/en/latest/api.html#hmmlearn.hmm.GMMHMM)? You can initialise it using a list of `sklearn.mixture.GMM` objects. – sietschie May 01 '16 at 19:06