Beispiel #1
0
 def test_viterbi_case3(self, part_1_a, viterbi):
     evidence = [40]
     prob_ans = 0.0392573919648
     seq_ans = ['B1']
     states, prior, trans, emiss = self.setup(part_1_a)
     seq, prob = viterbi(evidence, states, prior, trans, emiss)
     self.assertAlmostEqual(prob_ans, prob, places=7)
     self.assertEqual(seq_ans, seq)
     print_success_message("test_viterbi_case3")
Beispiel #2
0
 def test_viterbi_case2(self, part_1_a, viterbi):
     evidence = [50]
     prob_ans = 0.0167710014759
     seq_ans = ['H1']
     states, prior, trans, emiss = self.setup(part_1_a)
     seq, prob = viterbi(evidence, states, prior, trans, emiss)
     self.assertAlmostEqual(prob_ans, prob, places=7)
     self.assertEqual(seq_ans, seq)
     print_success_message("test_viterbi_case2")
Beispiel #3
0
 def test_viterbi_case1(self, part_1_a, viterbi):
     evidence = []
     states, prior, trans, emiss = self.setup(part_1_a)
     seq, prob = viterbi(evidence, states, prior, trans, emiss)
     msg = ('when evidence is an empty list, return "None" or [], '
             'get {}').format(seq)
     self.assertTrue(seq in [None, []], msg)
     msg = ('when evidence is an empty list, return prob=0.0, '
             'get {}').format(prob)
     self.assertTrue(prob == 0., msg)
     print_success_message("test_viterbi_case1")
Beispiel #4
0
 def test_viterbi_realsample3(self, part_1_a, viterbi):
     """
     Extracted from BOSTON ASL dataset: video 47, frame 21-30
     Actual words: CAR
     """
     evidence = [47, 39, 32, 34, 36, 42, 42, 42, 34, 25]
     prob_ans = 6.07498784245e-16
     seq_ans = ['H1', 'H2', 'H2', 'H2', 'H2', 'H2', 'H2', 'H2', 'H2', 'H2']
     states, prior, trans, emiss = self.setup(part_1_a)
     seq, prob = viterbi(evidence, states, prior, trans, emiss)
     self.assertAlmostEqual(prob_ans, prob, places=20)
     self.assertEqual(seq_ans, seq)
     print_success_message("test_viterbi_realsample3")
Beispiel #5
0
 def test_viterbi_realsample2(self, part_1_a, viterbi):
     """
     Extracted from BOSTON ASL dataset: video 48, frame 27-35
     Actual words: CAR
     """
     evidence = [45, 45, 46, 48, 51, 51, 49, 45, 42]
     prob_ans = 6.3377763423e-13
     seq_ans = ['H1', 'H1', 'H1', 'H1', 'H1', 'H1', 'H1', 'H1', 'H1']
     states, prior, trans, emiss = self.setup(part_1_a)
     seq, prob = viterbi(evidence, states, prior, trans, emiss)
     self.assertAlmostEqual(prob_ans, prob, places=17)
     self.assertEqual(seq_ans, seq)
     print_success_message("test_viterbi_realsample2")
Beispiel #6
0
 def test_viterbi_realsample1(self, part_1_a, viterbi):
     """
     Extracted from BOSTON ASL dataset: video 51, frame 17-23
     Actual words: BUY
     """
     evidence = [44, 51, 57, 63, 61, 60, 59]
     prob_ans = 3.81226460569e-11
     seq_ans = ['B1', 'B2', 'B2', 'B2', 'B2', 'B2', 'B2']
     states, prior, trans, emiss = self.setup(part_1_a)
     seq, prob = viterbi(evidence, states, prior, trans, emiss)
     self.assertAlmostEqual(prob_ans, prob, places=14)
     # print(seq)
     self.assertEqual(seq_ans, seq)
     print_success_message("test_viterbi_realsample1")