HMM Python中的转换矩阵

时间:2014-02-13 20:38:55

标签: python

我一直在使用HMMpytk(在Windows操作系统中)开发一个隐马尔可夫模型。在导出转换矩阵时,我得到一个关键错误。我的代码如下:

hmm_model = hmm_faster.HMM()
hmm_model.set_states(['GEN' , 'NICHTGEN'])
hmm_model.set_observations(['x', 'y', 'z'])

hmm_model.randomize_matrices(seed = 10)

start_probability = {'GEN' : startToGene, 'NICHTGEN': startToNotGene}

transition_probability = {'GEN':{'geneToGene':a, 'geneToNotGene':b}, 'NICHTGEN':      {'notGeneToGene':c, 'notGeneToNotGene':d}}

hmm_model.set_initial_matrix(start_probability)
hmm_model.set_transition_matrix(transition_probability)

transition_probability中的a,b,c和d是赋值给它们的浮点值的变量。

错误说:

self.trans_matrix[self.st_list_index[st_i]][self.st_list_index[st_j]]=A_matrix[st_i][st_j]
KeyError: 'notGeneToNotGene'

0 个答案:

没有答案