Code Monkey home page Code Monkey logo

ssm's Introduction

SSM: Bayesian learning and inference for state space models

Test status

This package has fast and flexible code for simulating, learning, and performing inference in a variety of state space models. Currently, it supports:

  • Hidden Markov Models (HMM)
  • Auto-regressive HMMs (ARHMM)
  • Input-output HMMs (IOHMM)
  • Hidden Semi-Markov Models (HSMM)
  • Linear Dynamical Systems (LDS)
  • Switching Linear Dynamical Systems (SLDS)
  • Recurrent SLDS (rSLDS)
  • Hierarchical extensions of the above
  • Partial observations and missing data

We support the following observation models:

  • Gaussian
  • Student's t
  • Bernoulli
  • Poisson
  • Categorical
  • Von Mises

HMM inference is done with either expectation maximization (EM) or stochastic gradient descent (SGD). For SLDS, we use stochastic variational inference (SVI).

Examples

Here's a snippet to illustrate how we simulate from an HMM.

import ssm
T = 100  # number of time bins
K = 5    # number of discrete states
D = 2    # dimension of the observations

# make an hmm and sample from it
hmm = ssm.HMM(K, D, observations="gaussian")
z, y = hmm.sample(T)

Fitting an HMM is simple.

test_hmm = ssm.HMM(K, D, observations="gaussian")
test_hmm.fit(y)
zhat = test_hmm.most_likely_states(y)

The notebooks folder has more thorough, complete examples of HMMs, SLDS, and recurrent SLDS.

Installation

git clone [email protected]:slinderman/ssm.git
cd ssm
pip install numpy cython
pip install -e .

This will install "from source" and compile the Cython code for fast message passing and gradients.

To install with some parallel support via OpenMP, first make sure that your compiler supports it. OS X's default Clang compiler does not, but you can install GNU gcc and g++ with conda. Once you've set these as your default, you can install with OpenMP support using

USE_OPENMP=True pip install -e .

ssm's People

Contributors

slinderman avatar bantin avatar davidzoltowski avatar jglaser2 avatar em812 avatar ahwillia avatar zashwood avatar guyhwilson avatar jchutrue avatar masonhargrave avatar ekellbuch avatar bagibence avatar wingillis avatar gaoyuanjun avatar ghuckins 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.