Git Product home page Git Product logo

imm's Introduction

imm

Join the chat at https://gitter.im/tscholak/imm

imm is a Python package for Bayesian MCMC inference in infinite mixture models. It is partially implemented in Cython for speed.

imm's main purpose is the clustering of multidimensional data in cases in which the number of clusters is not exactly known.

Currently, imm supports the following nonparametric models:

  • the Dirichlet process (DP) mixture model and
  • the mixture of finite mixtures (MFM) model.

The base measure can be either

  • a multivariate normal distribution with a conjugate normal-Wishart prior or
  • a multivariate normal with a conditionally conjugate normal-Wishart prior.

I will release proper documentation eventually. For now, have a look at the tutorial section below.

Getting started

To install imm manually from the GitHub repository, clone it and do python setup.py install --user. Required are recent Cython and SciPy installations.

First steps

Below I demonstrate how to address a simple inference problem in imm.

import imm

mm = imm.models.ConjugateGaussianMixture(
    xi=[0.,0.],
    rho=.1,
    beta=2.5,
    W=[[1.5,.5],[.5,1.5]])

pm = imm.models.DP(mm, alpha=1.25, seed=1)

x_n, c_n = pm.draw(size=2000)

This will generate data of the following form:

DP example

Now we will try to infer the labels from the data:

s = imm.samplers.CollapsedSAMSSampler(pm, max_iter=500, warmup=0)

c_n_sams, _ = pm.infer(x_n, sampler=s)

The result, c_n_sams, is very similar to the original set of labels, c_n:

SAMS example

Each of the 500 iterations produces a set of labels. This process can be visualized as an animation:

click to play

The algorithm manages to find most of the clusters already in the first couple of iterations. The noisy switching of some of the labels demonstrates the remaining uncertainty of the model predictions, which is inherent to the Bayesian approach.

Acknowledgments, credits, and contact info

Credit goes to Hanna Wallach (UMass Amherst), whose DPMM project laid the foundation for the present code. The unified approach, the application to (conditionally) conjugate Gaussian mixture models, the mixture of finite mixtures model, and the SAMS sampler is my doing.

Although the code underwent and continues to undergo significant testing, please understand that I cannot give a guarantee that it is correct or will produce correct results. If you find an error, open an issue or drop me an email at [email protected].

imm's People

Contributors

gitter-badger avatar tscholak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  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.