hmm_model
Typer | Posted on | |
pip install hidden_markov
import numpy as np
from hidden_markov import hmm
ob_types = ('W', 'N') # Working and Not Working
states = ('L', 'M') # Legitimate and Malicious
observations = ('W', 'W', 'W', 'N')
start = np.matrix('0.1 0.9') # Initial state probabilities
transition = np.matrix('0.7 0.3; 0.1 0.9') # Transition probabilities
emission = np.matrix('0.2 0.8; 0.4 0.6') # Emission probabilities
_hmm = hmm(states, ob_types, start, transition, emission)
print("Forward algorithm:")
print(_hmm.forward_algo(observations))
print("Viterbi algorithm:")
print(_hmm.viterbi(observations))