Thomas, a library for working with Bayesian Networks.
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:
- 6a. Inference by Variable Elimination I (Chapter 6).
- 6b. Inference by Variable Elimination II (Chapter 6).
Table of contents
To install the latest version from PyPI:
pip install thomas-core
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.
If you don't feel like installing thomas locally, there are two alternative ways to give the platform a try.
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
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:
- notebooks/1. Factors.ipynb
- notebooks/2. Bags of factors.ipynb
- notebooks/3. Conditional probability tables.ipynb
- notebooks/4. Bayesian Networks.ipynb
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
To do a development install:
git clone https://github.com/mellesies/thomas-core cd thomas-core pip install -e .
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for thomas_core-0.1.3-py3-none-any.whl