예제 #1
0
파일: test_hmm.py 프로젝트: ougni/HMM
def compare_recusions():
    # Compare the two version in terms of efficiency
    start_time = time.time()
    hmm = Hmm('rescaled')
    hmm.compute_proba()
    hmm.EM()
    print("rescaled version run in %.6s seconds " % (time.time() - start_time))

    start_time = time.time()
    hmm2 = Hmm('log-scale')
    hmm2.compute_proba()
    hmm2.EM()
    print("log-scale version run in %.6s seconds " %
          (time.time() - start_time))

    print('difference cond_proba ' % np.min(hmm.cond_proba - hmm2.cond_proba),
          np.max(hmm.cond_proba - hmm2.cond_proba))
    print(
        'difference joined_cond_proba' %
        np.min(hmm.joined_cond_proba - hmm2.joined_cond_proba),
        np.max(hmm.joined_cond_proba - hmm2.joined_cond_proba))
    return
예제 #2
0
파일: test_hmm.py 프로젝트: ougni/HMM
# Q1
print('\n****************** Q1 ******************')
compare_recusions()

# Q2
print('\n****************** Q2 ******************')
hmm = Hmm('rescaled')
hmm2 = Hmm('log-scale')
hmm.compute_proba(hmm.test_data)
hmm.plot_proba(100, 'conditional proba with initial parameters on test', 'q02',
               '1')

#Q3 & Q4
print('\n****************** Q4 ******************')
hmm.EM(True)
hmm.print_parameters()

# Q5
print('\n****************** Q5 ******************')
hmm.plot_likelihood('q05', '1')

# Q6
print('\n****************** Q6 ******************')
hmm.print_loglikelihoods_table()

# Q7-Q8


def plot_Viterbi_path(hmm):
    hmm.compute_proba()