HMMlearn Gaussian Mixture: set mean, weight and variance of each mixture component

时间秒杀一切 提交于 2021-02-08 10:33:53

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/36970387/hmmlearn-gaussian-mixture-set-mean-weight-and-variance-of-each-mixture-compone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!