Scikit Learn Gaussian HMM: ValueError: startprob should sum up to 1.0

I am currently working with Scikit Learn and participated in the next issue, trying to train a Gaussian HMM:

File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 443, customized

self._do_mstep(stats, self.params) 

File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 798, in _do_mstep

 super(GaussianHMM, self)._do_mstep(stats, params) 

File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 580, in _do_mstep

 np.maximum(self.startprob_prior - 1.0 + stats['start'], 1e-20)) 

File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 476, in _set_startprob

 raise ValueError('startprob must sum to 1.0') 

ValueError: startprob should sum up to 1.0

If I exclude some functions (less than 13 functions for observation), it still works. I checked that all the input is valid and consists of only 2d numpy.float64s 2d arrays for each training example. Any ideas on what's going wrong? Thanks!

+4
source share
4 answers

I fixed the problem by setting the params attribute to the set of all unique values ​​in my training set.

 param=set(train.ravel()) model=hmm.GaussianHMM(n_components=6, covariance_type="full", n_iter=100,params=param) 

train is my list of numpy arrays used to match the model.

In the initial parameters, a string of all ascii characters is specified.

+3
source

I just struggled with the same issue when using GaussianHMM. I realized that the problem was that I was feeding integer classifier values, and a float value was required instead. I tried using floating point numbers when I realized that MultinomialHMM only accepts continuous values, and it worked!

+1
source

I had the same problem. I could solve this by setting the number of hidden states of the model. It seems that, depending on the available data and the number of states, the model cannot correspond qualitatively

0
source

The model just has problems setting up data. You could through a little code around it to continue trying. You might want to add a little to stop it after x attempts. If this still does not work, change the number of hidden states.

 while True: try: model.fit([data]) break 
0
source

Source: https://habr.com/ru/post/1502138/


All Articles