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
Normal
To install from PyPI use pip
:
pip install thomas-core
Development
To do a development install:
git clone https://github.com/mellesies/thomas-core
cd thomas-core
pip install -e .
Docker
A Docker image is available for easy deployment. The following command will
start a JupyterLab server, listening on localhost
, port 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
Hashes for thomas_core-0.1.1a18-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 428c2385f1241aabfc3cac48156452147be737e08bd89deb5b7a247fc2e1c0e1 |
|
MD5 | 271d97b6c44c0e61fd294bd02a72e391 |
|
BLAKE2b-256 | e31a4e9f2549a5aab5fdbd285c4412acaabafd6ee14357afb6e56fd9cbada81c |