-
Notifications
You must be signed in to change notification settings - Fork 12
Home
FactorialHMM is a Python package for fast exact inference in Factorial Hidden Markov Models.
Our package allows:
- Simulating directly from the model
- Simulating from the posterior distribution of states given the observations
- Calculating the (Viterbi) sequence of states with the largest posterior probability
- Calculating the Forward-Backward algorithm, and in particular likelihood of the data and the posterior probability (given all observations) of the marginal and joint state probabilities as well as additional HMM-related procedures.
The running time and space requirement of all procedures is linear in the number of possible states. This package is highly modular, providing the user with maximal flexibility for developing downstream applications.
Currently, the models are discrete-hidden-state, discrete-time, while observations may be discrete or continuous.
To use FactorialHMM, you need to subclass one of the provided classes, implement some of the methods, and create an instance of the class. Generally, you'd want FactorialHMMDiscreteObserved
for discrete observations and FactorialHMMGeneralObserved
otherwise. Both classes inherit from FactorialHMM
.
This would generally look like this:
from factorial_hmm import *
class MyFactorialHMM(...): # Choose one of the suitable classes here
# Implement methods
def SetTransitionMatricesTensor(self):
# Stuff here...
# Other methods to implement, see docs
See here for the full details.
After you have constructed an object, you can perform various calculations with it. This would generally look like this:
# Initialize
H = MyFactorialHMM(...)
# Work with object, e.g.:
X = H.Simulate()
See here for the full details.