🤔 hmmm 🤔
Hidden Markov Models in Rust.
This library contains a Rust implementation of a time-invariant Hidden Markov model with discrete observations. It includes maximum likelihood estimation via the Baum-Welch expectation-maximization algorithm and hidden state inference via the Viterbi algorithm.
See hmmm::HMM for detailed documentation on how to work with this library.
Below, the HMM is trained to recognize the pattern 001001001...
use HMM;
use ;
use SeedableRng as _;
let training_ys = array!;
let mut rng = seed_from_u64;
let hmm = HMMtrain;
let sampled_ys: = hmm.sampler
.map
.take
.collect;
assert_eq!;
Building
This project uses cargo-make. See Makefile.toml for a full list of build commands, but the
main useful command for this project is cargo make all.
There is a small amount of benchmarking functionality gated by the benchmark feature.
Notes
Sections 17.3 and 17.4 of Machine Learning a Probabilistic Perspective by Kevin Murphy, 2012 were invaluable as a reference, as was section 13.2 of Pattern Recognition and Machine Learning by Christopher Bishop, 2016.
I have attempted to make the math notation readable both as rendered HTML and from the source code. The notation is strongly inspired by the Wikipedia page on the Baum-Welch algorithm.
License: MIT/Apache-2.0