我正在尝试用我观察到的数据拟合多项式模型。我有一个包含不同长度轨迹的数据集。由于我的观察是离散的,我尝试拟合多项式模型。观察符号的数量为 3147,轨迹(序列)的数量为 4760。虽然我给出了观察序列(X 具有在 hmmlearn 类中定义的数组形状)和观察的长度(),以使用此代码拟合方法:
X
array([[31],
[ 1],
[17],
...,
[ 4],
[ 1],
[16]])
lengths
[28,
6,
11,
7,
2,
2,
...]
model = hmm.MultinomialHMM(n_components=10).fit(X, lengths)
我有一个错误。有人可以帮助我并解释我做错了什么。谢谢。
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-72-565aadfd0ae4> in <module>()
----> 1 model = hmm.MultinomialHMM(n_components=10).fit(X, lengths)
C:\Python\Anaconda2\lib\site-packages\hmmlearn\base.pyc in fit(self, X, lengths)
427 curr_logprob = 0
428 for i, j in iter_from_X_lengths(X, lengths):
--> 429 framelogprob = self._compute_log_likelihood(X[i:j])
430 logprob, fwdlattice = self._do_forward_pass(framelogprob)
431 curr_logprob += logprob
C:\Python\Anaconda2\lib\site-packages\hmmlearn\hmm.pyc in _compute_log_likelihood(self, X)
403
404 def _compute_log_likelihood(self, X):
--> 405 return np.log(self.emissionprob_)[:, np.concatenate(X)].T
406
407 def _generate_sample_from_state(self, state, random_state=None):
IndexError: index 3147 is out of bounds for axis 1 with size 3147