本文整理汇总了Python中Bio.MarkovModel._mle方法的典型用法代码示例。如果您正苦于以下问题:Python MarkovModel._mle方法的具体用法?Python MarkovModel._mle怎么用?Python MarkovModel._mle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.MarkovModel
的用法示例。
在下文中一共展示了MarkovModel._mle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mle
# 需要导入模块: from Bio import MarkovModel [as 别名]
# 或者: from Bio.MarkovModel import _mle [as 别名]
def test_mle(self):
states = ["0", "1", "2", "3"]
alphabet = ["A", "C", "G", "T"]
training_data = [("AACCCGGGTTTTTTT", "001112223333333"),
("ACCGTTTTTTT", "01123333333"),
("ACGGGTTTTTT", "01222333333"),
("ACCGTTTTTTTT", "011233333333"), ]
training_outputs = array([[0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3], [
0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3], [0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3], [0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3]])
training_states = array([[0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3], [
0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3], [0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3], [0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3]])
p_initial = array([1., 0., 0., 0.])
p_transition = array([[0.2, 0.8, 0., 0.],
[0., 0.5, 0.5, 0.],
[0., 0., 0.5, 0.5],
[0., 0., 0., 1.]])
p_emission = array(
[[0.66666667, 0.11111111, 0.11111111, 0.11111111],
[0.08333333, 0.75, 0.08333333, 0.08333333],
[0.08333333, 0.08333333, 0.75, 0.08333333],
[0.03125, 0.03125, 0.03125, 0.90625]])
p_initial_out, p_transition_out, p_emission_out = MarkovModel._mle(
len(states), len(alphabet), training_outputs, training_states, None, None, None)
self.assertTrue(
array_equal(around(p_initial_out, decimals=3), around(p_initial, decimals=3)))
self.assertTrue(
array_equal(around(p_transition_out, decimals=3), around(p_transition, decimals=3)))
self.assertTrue(
array_equal(around(p_emission_out, decimals=3), around(p_emission, decimals=3)))