Skip to main content

Thomas, a library for working with Bayesian Networks.

Project description

Coverage Status Build Status badge

Thomas

Very simple (almost naive ;-) bayesian network implementation.

Contains examples (thomas.core.examples) from the book "Probabilistic Graphical Models: Principles and Techniques" from Koller and Friedman (PGM Stanford) and from the lecture by Adnan Darwiche on YouTube:

Table of contents

  1. Regular Installation
  2. Alternatives
  3. Usage
  4. Development installation

img

Regular installation

To install the latest version from PyPI:

pip install thomas-core

Additional packages

If you're using JupyterLab, I recommend also installing the Widget that can display Bayesian Networks.

pip install thomas-jupyter-widget

See the repository (or the screenshot above) for details on how to use it.

Alternatives

If you don't feel like installing thomas locally, there are two alternative ways to give the platform a try.

Docker

If you have docker available, the following command will start a JupyterLab server listening on http://localhost:8888:

docker run --rm -it -p 8888:8888 mellesies/thomas-core

Binder

mybinder.org courteously provides an environment where you can try out Thomas without any local installation. Just click here (or the badge above) and after some waiting, JupyterLab should open in your browser.

You can also directly open one of the example notebooks:

Usage

To get started with querying a network, launch python3 and try the following:

from thomas.core import examples

# Load an example network
Gs = examples.get_student_network()

# This should output the prior probability of random variable 'S' (SAT score).
print(Gs.P('S'))
print()

# Expected output:
# P(S)
# S
# s0    0.725
# s1    0.275
# dtype: float64

# Query for the conditional probability of S given the student is intelligent.
print(Gs.P('S|I=i1'))

# Expected output:
# P(S)
# S
# s0    0.2
# s1    0.8
# dtype: float64

Development installation

To do a development install:

git clone https://github.com/mellesies/thomas-core
cd thomas-core
pip install -e .

Project details


Download files

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

Files for thomas-core, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size thomas_core-0.1.3-py3-none-any.whl (108.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size thomas-core-0.1.3.tar.gz (98.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page