Skip to content

mellesies/thomas-core

Repository files navigation

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 .

About

Very simple (almost naive ;-) bayesian network implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published