本文整理汇总了Python中hmmlearn.hmm.GaussianHMM._do_backward_pass方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianHMM._do_backward_pass方法的具体用法?Python GaussianHMM._do_backward_pass怎么用?Python GaussianHMM._do_backward_pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hmmlearn.hmm.GaussianHMM
的用法示例。
在下文中一共展示了GaussianHMM._do_backward_pass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_backward_with_hmmlearn
# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import _do_backward_pass [as 别名]
def test_backward_with_hmmlearn(self):
r = np.random.randn
obs = [np.array([[-600 + r(), 100 + r()], [-300 + r(), 200 + r()], [0 + r(), 300 + r()]]) for _ in xrange(10)]
hmm = GaussianHMM(n_components=3)
hmm.fit(obs)
# Calculcate bwdlattice using hmmlearn algorithm
framelogprob = hmm._compute_log_likelihood(obs[0])
start = timeit.default_timer()
bwdlattice1 = hmm._do_backward_pass(framelogprob)
print('hmmlearn took %fs' % (timeit.default_timer() - start))
# Calculate bwdlattice using fhmm algorithm with #chains = 1. This should yield the exact same results
start = timeit.default_timer()
bwdlattice2 = np.zeros(bwdlattice1.shape)
fhmmc._backward(obs[0].shape[0], 1, hmm.n_components, [(x,) for x in xrange(hmm.n_components)],
hmm._log_startprob.reshape(1, 3), hmm._log_transmat.reshape(1, 3, 3), framelogprob, bwdlattice2)
print('fhmm took %fs' % (timeit.default_timer() - start))
self.assertTrue(np.allclose(bwdlattice1, bwdlattice2))