Scikit学习高斯HMM:ValueError:startprob必须总计为1.0 [英] Scikit Learn Gaussian HMM: ValueError: startprob must sum to 1.0
问题描述
我目前正在使用Scikit Learn,并且在尝试训练高斯HMM时遇到了以下问题:
I am currently working with Scikit Learn and have been running into the following issue while trying to train a Gaussian HMM:
适合的文件"/Library/Python/2.7/site-packages/sklearn/hmm.py",第443行
File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 443, in fit
self._do_mstep(stats, self.params)
文件"/Library/Python/2.7/site-packages/sklearn/hmm.py",行798,在_do_mstep中
File "/Library/Python/2.7/site-packages/sklearn/hmm.py", line 798, in _do_mstep
super(GaussianHMM, self)._do_mstep(stats, params)
文件"/Library/Python/2.7/site-packages/sklearn/hmm.py",第580行,位于_do_mstep中
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))
_set_startprob中的文件"/Library/Python/2.7/site-packages/sklearn/hmm.py",第476行
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的总和必须为1.0
ValueError: startprob must sum to 1.0
如果我删除了某些功能(每个观察少于13个功能),它仍然可以工作.我已经检查了所有输入是否有效,并且每个训练示例都仅包含numpy.float64s的2d数组.对出什么问题有任何想法吗? 谢谢!
If I eliminate some of the features (fewer than 13 features per observation), it still works. I have checked that all of the input is valid and consists of only 2d-arrays of numpy.float64s for each training example. Any ideas on what is going wrong? Thanks!
推荐答案
我通过将params属性设置为训练集中所有唯一值的集合来解决此问题.
I fixed the issue by setting the params attribute to a 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是我用来拟合模型的numpy数组的列表.
train is my list of numpy arrays used to fit the model.
初始参数设置为所有ascii字符的字符串.
The initial parameters are set to a string of all ascii characters.
这篇关于Scikit学习高斯HMM:ValueError:startprob必须总计为1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!