Git Product home page Git Product logo

variationalh3m.jl's Introduction

VariationalH3M

Reasonably fast, mostly correct, implementation of the VHEM-H3M (Variational Hierarchical EM - Hidden Markov Mixture Model) [1] algorithm for the clustering of HMMs (Hidden Markov Models).

This is mostly a translation of the equations to Julia code, with the use of log-values to improve numerical stability. It supports HMMs with GMM (Gaussian Mixture Model) emissions. The number of states, and of components per state, can be different between the HMMs. HMMs are specified using the HMMBase package.

This works reasonably well but there is room for improvement:

  • Initialization of the reduced H3M (something like K-means++ ?)
  • More in-place operations to reduce allocations
  • Proper separation of the E and M steps
  • Structure for summary statistics
  • Documentation, examples, tests ...
  • Profiling, optimization, cleanup ...

[1] Coviello, E., Chan, A. B., & Lanckriet, G. R. (2014). Clustering hidden Markov models with variational HEM. The Journal of Machine Learning Research, 15(1), 697-747. http://jmlr.org/papers/volume15/coviello14a/coviello14a.pdf

Usage

The package can be installed with the Julia package manager. From the Julia REPL, type ] to enter the Pkg REPL mode and run:

pkg> registry add https://github.com/maxmouchet/JuliaRegistry.git
pkg> add VariationalH3M
using Distributions, HMMBase, VariationalH3M

# Simulate a dataset of HMMs
randgmm(K) = MixtureModel([Normal(rand(Normal(0, 10)), 1) for _ in 1:K])
randhmm(K) = HMM(randtransmat(K), [randgmm(rand(1:5)) for _ in 1:K])
base_models = [randhmm(rand(1:10)) for _ in 1:100]

# Initialization
base = H3M(base_models)
redu = H3M(rand(base_models, 2))

# Clustering
τ = 10   # Length of the virtual sequences
N = 1000 # Number of virtual samples

hist, z, reducedp = cluster(base, redu, τ, N)

# hist: EM history (convergence, logtots)
# z: optimal assignments (base x reduced)
# reducedp: final reduced models

# To get an hard clustering (of the base models with respect to the reduced models),
# we can take the argmax of z:
labels = [x.I[2] for x in argmax(z, dims = 2)]

Development

└── src
    ├── api.jl       # High-level interface (`cluster`)
    ├── em.jl        # Variational E and M steps
    ├── h3m.jl       # H3M type
    ├── lse.jl       # Streaming log-sum-exp implementation
    ├── mc.jl        # Monte-Carlo expectations (not used)
    ├── va.jl        # Variational expectations
    └── VariationalH3M.jl  # Module definition

variationalh3m.jl's People

Contributors

maxmouchet avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.