https://github.com/vgherard/viterbi
Viterbi algorithm for optimal paths in Hidden Markov Models
https://github.com/vgherard/viterbi
algorithm dynamic-programming hidden-markov-model natural-language-processing part-of-speech-tagging
Last synced: 7 months ago
JSON representation
Viterbi algorithm for optimal paths in Hidden Markov Models
- Host: GitHub
- URL: https://github.com/vgherard/viterbi
- Owner: vgherard
- Created: 2021-01-11T11:28:33.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-12T11:00:17.000Z (almost 5 years ago)
- Last Synced: 2025-02-06T11:53:03.973Z (9 months ago)
- Topics: algorithm, dynamic-programming, hidden-markov-model, natural-language-processing, part-of-speech-tagging
- Language: C++
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# viterbi
The [Viterbi algorithm](https://en.wikipedia.org/wiki/Viterbi_algorithm) is a dynamic programming algorithm to find optimal paths in the hidden space of an hidden Markov model.
It has wide applications, including for Natural Language Processing tasks such as Part-of-Speech tagging.
Problem and algorithm descriptions are given below.
#### Example
Compile and link `example.cpp` and `viterbi.cpp`, e.g.:
```
$ g++ example.cpp viterbi.cpp -o example
$ ./example
```
You will be prompted to insert the data defining the model, and the input path in observable space.
#### Problem
Let
be an hidden Markov model, where:
-
: hidden space of finite cardinality
-
: observable space of finite cardinality
-
: transition matrix
-
: emission matrix
-
: start probabilities
Given a path
in observable space,
find a corresponding path
in hidden space
maximizing the conditional probability
or, equivalently, the joint probability })
#### Algorithm
The Viterbi algorithm is a dynamic programming procedure to solve the problem above. It is based on the optimization subproblems:
)
)
which can be solved recursively. For more info and pseudocode, c.f. the [Wikipedia article](https://en.wikipedia.org/wiki/Viterbi_algorithm).