Welcome to libpgm!

libpgm is an endeavor to make Bayesian probability graphs easy to use. The effort originates from Daphne Koller and Nir Friedman’s Probabilistic Graphical Models (2009), which provides an in-depth study of probabilistic graphical models and their applications.

libpgm was developed at CyberPoint Labs during the Summer of 2012 by Charles Cabot working under the direction of James Ulrich and Mark Raugas. It is provided free of use in accordance with the New BSD License:

Copyright (c) 2012, CyberPoint International, LLC
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the CyberPoint International, LLC nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL CYBERPOINT INTERNATIONAL, LLC BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Install from pypi at http://pypi.python.org/pypi/libpgm.

Documentation

The library consists of a series of importable modules, which either represent types of Bayesian graphs, contain methods to operate on them, or both. The methods’ individual documentation pages are found below:

Note that numpy, scipy, and Python 2.7 are required for this library.

Capabilities

Briefly, the capabilities of this library are:

  • Sampling
    • Forward sampling in a discrete-CPD Bayesian network
    • Forward sampling in a linear Gaussian-CPD Bayesian network
    • Forward sampling in a hybrid (any CPD type) Bayesian network
    • Forward sampling in a dynamic 2-TBN Bayesian network
    • Gibbs sampling in a discrete-CPD Bayesian network (given evidence)
  • Deterministic Inference
    • Compute the probability distribution over a specific node or nodes in a discrete-CPD Bayesian network (given evidence, if present)
    • Compute the exact probability of an outcome in a discrete-CPD Bayesian network (given evidence, if present)
  • Approximative Inference
    • Compute the approximate probability distribution by generating samples
  • Learning
    • Learn the CPDs of a discrete-CPD Bayesian network, given data and a structure
    • Learn the structure of a discrete Bayesian network, given only data
    • Learn the CPDs of a linear Gaussian Bayesian network, given data and a structure
    • Learn the strcutre of a linear Gaussian Bayesian network, given only data
    • Learn entire Bayesian networks (structures and parameters) from data

Input files

Because Bayesian probability graphs are large and contain a lot of data, the library works with .txt files as inputs. The formatting used is JavaScript Object Notation (JSON), with some flexibility (the dictionary module has the capacity to transform python-style dicts to JSON, for instance). Internally, the library stores these files as json objects from python’s json library. For examples of the formatting, and of the particular data required for each different Bayesian network type, see the example input files below:

Indices and tables

Table Of Contents

Next topic

dictionary

This Page