def test_backward_probability():
from numpy.testing import assert_array_almost_equal
model, states, symbols, seq = _wikipedia_example_hmm()
bp = 2**model._backward_probability(seq)
# examples in wikipedia are normalized
bp = (bp.T / bp.sum(axis=1)).T
wikipedia_results = [
# Forward-backward algorithm doesn't need b0_5,
# so .backward_probability doesn't compute it.
# [0.6469, 0.3531],
[0.5923, 0.4077],
[0.3763, 0.6237],
[0.6533, 0.3467],
[0.6273, 0.3727],
[0.5, 0.5],
]
assert_array_almost_equal(wikipedia_results, bp, 4)
test_hmm.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录