HMM-Baum-Welch-Algorithm
HMM-Baum-Welch-Algorithm copied to clipboard
Implementation of Baum-Welch (Forward-Backward) algorithm in Python.
Baum-Welch-Algorithm
Numpy Implementation of Baum-Welch (Forward-Backward) algorithm in Python.
This algorithm can run for any number of states and observations. The default example has two states (H&C) and three possible observations (emissions) namely 1, 2 and 3. Following are the matrices/variables that needs to be adjusted:
- Transition: contains intial transition probabilies. The value at [0,0] is transition from H to H and value at [1,1] is transition from C to C. (keeping in view the default example)
- emission: contains intial emission probabilies. The value at [0,0] is emission of symbol 1 from H and the value at [0,1] is emission of symbol 2 from H. (keeping in view the default example)
- states_dic: the dictionary that contains corresponding digits/indices for each state. The value starts from 0 and goes upto number of states for each state
- sequence_syms: simply a dictionary of all possible observations with their corresponding indices. Indices start from 0 and increment with each observation
- sequence: is a list of all possible observations
- test_sequence: a string containing the sequence on which we want to train our matrices
- threshold value that stops the algorithm can be adjusted in the very end of code