Skip to main content

A library for Probabilistic Graphical Models

Project description

pgmpy
=====
[![Build Status](https://travis-ci.org/pgmpy/pgmpy.svg?style=flat)](https://travis-ci.org/pgmpy/pgmpy)
[![Coverage Status](https://coveralls.io/repos/pgmpy/pgmpy/badge.svg?branch=dev)](https://coveralls.io/r/pgmpy/pgmpy?branch=dev)
[![Code Health](https://landscape.io/github/pgmpy/pgmpy/dev/landscape.svg?style=flat)](https://landscape.io/github/pgmpy/pgmpy/dev)
[![Join the chat at https://gitter.im/pgmpy/pgmpy](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pgmpy/pgmpy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

pgmpy is a python library for working with Probabilistic Graphical Models.

Documentation and list of algorithms we support is at our official site http://pgmpy.org/

Our mailing list is at https://groups.google.com/forum/#!forum/pgmpy .

We have our community chat at [gitter](https://gitter.im/pgmpy/pgmpy).

Dependencies
=============
pgmpy has following non optional dependencies:
- Python 2.7 or Python 3
- NetworkX 1.9.1
- Scipy 0.12.1
- Numpy 1.9.2
- Cython 0.21
- Pandas 0.15.1

Download
=========
Currently pgmpy is not hosted on pypi or conda.
You can either clone the git repo with:
```
git clone https://github.com/pgmpy/pgmpy
```
or download a zip from: https://github.com/pgmpy/pgmpy/archive/dev.zip

Installation
=============
To install the dependencies switch to the pgmpy directory using:
```
$ cd /path/to/pgmpy
```
In the directory run either of the following:

Using pip
```
$ pip install -r requirements.txt
```
or conda
```
$ conda intall --file requirements.txt
```

Then install using:

```bash
sudo python3 setup.py install
```

If you face any problems during installation let us know, via issues, mail or at our gitter channel.

Development
============

Code
----

You can check the latest sources from our github repository
use the command:

git clone https://github.com/pgmpy/pgmpy.git

Contributing
------------
Issues can be reported at our [issues section](https://github.com/pgmpy/pgmpy/issues) or via mail, or gitter.
We will try our best to solve the issue at the earliest.

Before opening a pull request , have look at our [contributing guide](
https://github.com/pgmpy/pgmpy/blob/dev/Contributing.md)

Contributing guide contains some points that will make our life's easier in reviewing and merging your PR.

If you face any problems in pull request, feel free to ask them at mail or gitter.

If you have any new features, please have a discussion on the issue tracker or the mailing
list before working on it.

Testing
-------

After installation, you can launch the test form pgmpy
source directory (you will need to have the ``nose`` package installed):
```bash
$ nosetests -v
```
to see the coverage of existing code use following command
```
$ nosetests --with-coverage --cover-package=pgmpy
```

Documentation and usage
=======================

Everything is at:
http://pgmpy.org/

You can also build the documentation in your local system. We use sphinx to help us building documentation from our code.
```
$ cd /path/to/pgmpy/docs
$ make html
```
Then the docs will be in _build/html

Example:
========
Here is a small snippet of pgmpy API
```
python3
>>> from pgmpy.models import BayesianModel
>>> from pgmpy.factors import TabularCPD
>>> student = BayesianModel()
>>> # instantiates a new Bayesian Model called 'student'

>>> student.add_nodes_from(['diff', 'intel', 'grade'])
>>> # adds nodes labelled 'diff', 'intel', 'grade' to student

>>> student.add_edges_from([('diff', 'grade'), ('intel', 'grade')])
>>> # adds directed edges from 'diff' to 'grade' and 'intel' to 'grade'

>>> """
... diff cpd:
...
... +-------+--------+
... |diff: | |
... +-------+--------+
... |easy | 0.2 |
... +-------+--------+
... |hard | 0.8 |
... +-------+--------+
... """

>>> diff_cpd = TabularCPD('diff', 2, [[0.2], [0.8]])

>>> """
... intel cpd:
...
... +-------+--------+
... |intel: | |
... +-------+--------+
... |dumb | 0.5 |
... +-------+--------+
... |avg | 0.3 |
... +-------+--------+
... |smart | 0.2 |
... +-------+--------+
... """

>>> intel_cpd = TabularCPD('intel', 3, [[0.5], [0.3], [0.2]])

>>> """
... grade cpd:
...
... +------+-----------------------+---------------------+
... |diff: | easy | hard |
... +------+------+------+---------+------+------+-------+
... |intel:| dumb | avg | smart | dumb | avg | smart |
... +------+------+------+---------+------+------+-------+
... |gradeA| 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 |
... +------+------+------+---------+------+------+-------+
... |gradeB| 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 |
... +------+------+------+---------+------+------+-------+
... |gradeC| 0.8 | 0.8 | 0.8 | 0.8 | 0.8 | 0.8 |
... +------+------+------+---------+------+------+-------+
... """

>>> grade_cpd = TabularCPD('grade', 3,
[[0.1,0.1,0.1,0.1,0.1,0.1],
[0.1,0.1,0.1,0.1,0.1,0.1],
[0.8,0.8,0.8,0.8,0.8,0.8]],
evidence=['intel', 'diff'],
evidence_card=[3, 2])

>>> student.add_cpds(diff_cpd, intel_cpd, grade_cpd)

>>> # Finding active trail
>>> student.active_trail_nodes('diff')
{'diff', 'grade'}

>>> # Finding active trail with observation
>>> student.active_trail_nodes('diff', observed='grade')
{'diff', 'intel'}

```
Lisence
=======
pgmpy is released under MIT License. You can read about our lisence at [here](https://github.com/pgmpy/pgmpy/blob/dev/LICENSE)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgmpy-0.1.0.tar.gz (149.9 kB view details)

Uploaded Source

File details

Details for the file pgmpy-0.1.0.tar.gz.

File metadata

  • Download URL: pgmpy-0.1.0.tar.gz
  • Upload date:
  • Size: 149.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pgmpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98bf5add9ac30fe102e92adcd7888bd3c4fe1edd06cf25941ebbc635fb41bd7f
MD5 857d38203d7575cefab54d9bac632055
BLAKE2b-256 586911174fa27b828a203c5711a9887e9348c2b5b34ea3a82a5735bb889b2e48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page