当前位置: 首页>>代码示例>>Python>>正文


Python HMM.populate_alphabets方法代码示例

本文整理汇总了Python中hmm.HMM.populate_alphabets方法的典型用法代码示例。如果您正苦于以下问题:Python HMM.populate_alphabets方法的具体用法?Python HMM.populate_alphabets怎么用?Python HMM.populate_alphabets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hmm.HMM的用法示例。


在下文中一共展示了HMM.populate_alphabets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from hmm import HMM [as 别名]
# 或者: from hmm.HMM import populate_alphabets [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
开发者ID:flosincapite,项目名称:machine-learning,代码行数:27,代码来源:test_hmm.py


注:本文中的hmm.HMM.populate_alphabets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。