2.5 KiB
2.5 KiB
In [ ]:
ob_types = ('W','N')
# W for working and N for not working
states = ('L','M')
#M is the malicious and L is LegitimateIn [ ]:
import numpy as np
observation = ('W','W','W','N')
start = np.matrix('0.1 0.9')
transition = np.matrix('0.7 0.3 ; 0.1 0.9')
emission = np.matrix('0.2 0.8 ; 0.4 0.6')In [ ]:
from hidden_markov import hmm
ob_types = ('W','N')
# W for working and N for not working
states = ('L','M')
#M is the malicious and L is Legitimate
observation = ('W','W','W','N')
start = np.matrix('0.1 0.9')
transition = np.matrix('0.7 0.3 ; 0.1 0.9')
emission = np.matrix('0.2 0.8 ; 0.4 0.6')
_hmm = hmm(states, ob_types, start, transition,emission)
print("Forward algorithm")
print(_hmm.forward_algo(observation))
print("Viterbi algorithm: ")
print(_hmm.viterbi(observation))