Thomas, a library for working with Bayesian Networks.
Project description
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: * 6a. Inference by
Variable Elimination I (Chapter
6). * 6b. Inference by Variable
Elimination II (Chapter 6).
Installation
Regular installation
To install the latest version from PyPI:
pip install thomas-core
Install from PyyPI TEST:
pip install -i https://test.pypi.org/simple/ --extra-index-url=https://pypi.python.org/simple thomas-core
pip install -i https://test.pypi.org/simple/ --extra-index-url=https://pypi.python.org/simple thomas-jupyter-widget
To install the latest version from source:
pip install git+https://github.com/mellesies/thomas-core
Development installation
To do a development install:
git clone https://github.com/mellesies/thomas-core
cd thomas-core
pip install -e .
Additional packages
If you're using JupyterLab, I'd recommend also installing the Widget that can display Bayesian Networks.
Docker
A Docker image is available should you just want to try things out.The following command will start a JupyterLab server, listening on http://localhost:8888.
docker run --rm -it -p 8888:8888 mellesies/thomas-core
Usage
To get started with querying a network, 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
Alternatively, you can have a go at the example notebooks through Binder:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file thomas-core-0.1.1.tar.gz
.
File metadata
- Download URL: thomas-core-0.1.1.tar.gz
- Upload date:
- Size: 95.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21c44bfc469db0b5d9359d660f09333f8f6f874ed0f404be4f4a3717ccb4d19e |
|
MD5 | c771b238818e84bf1eda98b8237f61b7 |
|
BLAKE2b-256 | 98653137fe0b9b9d269b4d1bb47de4045d14f2954ffe4845de57779a013130f5 |
File details
Details for the file thomas_core-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: thomas_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 102.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3de18c22c9cdc6d569c1276902608a995b524582618e89a0d5a3e5fa6f1a8a64 |
|
MD5 | 506d8ef1657e8a6008b823b905ac31f0 |
|
BLAKE2b-256 | de1e7f61352ed862fab2dd3bfcf6fdf508c718c0a24a8cea21d3a0fdbaf43466 |