本文整理汇总了Python中hmm.HMM.transition_matrix[cold_index,hot_index]方法的典型用法代码示例。如果您正苦于以下问题:Python HMM.transition_matrix[cold_index,hot_index]方法的具体用法?Python HMM.transition_matrix[cold_index,hot_index]怎么用?Python HMM.transition_matrix[cold_index,hot_index]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hmm.HMM
的用法示例。
在下文中一共展示了HMM.transition_matrix[cold_index,hot_index]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from hmm import HMM [as 别名]
# 或者: from hmm.HMM import transition_matrix[cold_index,hot_index] [as 别名]
def setUp(self):
week0 = Instance(label=['Hot', 'Cold', 'Hot', 'Cold'], data=['good', 'bad', 'good', 'bad'])
week1 = Instance(label=['Cold', 'Cold', 'Cold'], data=['good', 'bad', 'bad'])
week2 = Instance(label=['Hot', 'Hot', 'Hot'], data=['good', 'good', 'good'])
self.training_set = [week0, week1, week2]
hmm = HMM()
hmm.populate_alphabets(self.training_set)
hot_index = hmm.label_alphabet.get_index('Hot')
cold_index = hmm.label_alphabet.get_index('Cold')
good_index = hmm.feature_alphabet.get_index('good')
bad_index = hmm.feature_alphabet.get_index('bad')
hmm.initial_probability = numpy.array([1, 1])
#if the week starts out hot, it must stay hot. If cold, stay cold
# HHH and CCC are allowed
hmm.transition_matrix[hot_index, cold_index] = 0
hmm.transition_matrix[hot_index, hot_index] = 1 - hmm.transition_matrix[hot_index, cold_index]
hmm.transition_matrix[cold_index, hot_index] = 0
hmm.transition_matrix[cold_index, cold_index] = 1 - hmm.transition_matrix[cold_index, hot_index]
hmm.emission_matrix[hot_index, good_index] = 0.75
hmm.emission_matrix[hot_index, bad_index] = 1 - hmm.emission_matrix[hot_index, good_index]
hmm.emission_matrix[cold_index, good_index] = 0.50
hmm.emission_matrix[cold_index, bad_index] = 1 - hmm.emission_matrix[cold_index, good_index]
self.hmm = hmm