Markov models for categorical sequential data in Python. The joint probabiity
for an ordered sequence of the categorical variable
is composed of M+1 conditional distributions of order
. Each component
is represented by a rank m+1 tensor of transition state probabilities. These are inferred under maximum likelihood estimation of the data.
import numpy as np
from pymm.models import MarkovModel
# number of states for categorical variable
K = 2
# order of Markov model
M = 1
# generator for synthetic data
generator = MarkovModel(K=K, M=M, random_init=True)
# create artificial sequential dataset
X = [generator.sample(10) for _ in range(1000)]
# Markov model to infer joint distribution for sequential data
model = MarkovModel(K=K, M=M)
# infer conditional transition state probabilities
%timeit -r 1 -n 1 model.fit(X)To install, download or git clone the full repository and then run
python setup.py install
from the repository root in your chosen python environment. PyPi release to follow.
This repository is pre-release and in active development. Please check for updates and switch to the PyPi release when available.