Expand description
§Karma - Hidden Markov Model Implementation
A sophisticated and efficient implementation of Hidden Markov Models (HMM) using the Baum-Welch algorithm for training and the Forward algorithm for evaluation.
§Overview
Hidden Markov Models are statistical models used to represent systems that transition between hidden states while producing observable outputs. This implementation provides:
- Training: Baum-Welch algorithm (Forward-Backward) for parameter estimation
- Evaluation: Forward algorithm for computing observation sequence probabilities
- Efficient: Optimized matrix operations with minimal allocations
- Type-safe: Strong type safety with comprehensive error handling
§Example
use karma::HiddenMarkovModel;
// Create an HMM with 3 hidden states and 2 possible observations
let mut hmm = HiddenMarkovModel::new(3, 2).unwrap();
// Train on observation sequences
hmm.train(&[0, 1, 0, 1], None).unwrap();
hmm.train(&[1, 1, 0], Some(0.1)).unwrap();
// Evaluate probability of a new sequence
let probability = hmm.evaluate(&[0, 1, 1]).unwrap();
println!("Sequence probability: {}", probability);Structs§
- Hidden
Markov Model - A Hidden Markov Model with discrete observations
- HmmBuilder
- Builder for constructing Hidden Markov Models
Enums§
- HmmError
- Errors that can occur during HMM operations