Skip to content
Python code for doing k-Best or List decoding with the Viterbi algorithm
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Python code for doing k-Best or List Viterbi Decoding of a HMM

viterbi(pi, A, O, observations)

A reference implementation of the Viterbi algorithm, robbed from here:-

exhaustive(pi, A, O, observations)

Exhaustively compute all possibilities for the HMM, robbed from here:-

kViterbiParallel(pi, a, b, obs, k)

Parallel List Viterbi Decoder to retain the top k scoring paths at each state at each time t in the time series.

Adapted from the outline in this paper:-

kViterbiGraph(pi, a, b, obs, k)

Compute a k length Viterbi list by first converting the HMM into a NetworkX compatible DAG (Directed acyclic graph), converting to negative log-space then using Yen's algorithm to return the shortest paths, see this paper below.

There are also some models for testing, namely the Wikipedia exam[ple and tcohn's example above.

You can’t perform that action at this time.