Thomas, a library for working with Bayesian Networks.
Project description
Thomas
Very simple (almost naive ;-) bayesian network implementation.
Example (module thomas.core.examples
) contains 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 desployment. 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
File details
Details for the file thomas-core-0.1.0a15.tar.gz
.
File metadata
- Download URL: thomas-core-0.1.0a15.tar.gz
- Upload date:
- Size: 671.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bfcfbb74eba260890af1e9d2702b7ac244e7f4566a609a386e9c1e03c407e57 |
|
MD5 | 2ae238c18b08d390c9fd24a0d380dda7 |
|
BLAKE2b-256 | 404a0b1ee7c5044aaf5b17b76a3c81fc697279dcd21d844e314f46e89c8d7201 |
File details
Details for the file thomas_core-0.1.0a15-py3-none-any.whl
.
File metadata
- Download URL: thomas_core-0.1.0a15-py3-none-any.whl
- Upload date:
- Size: 74.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9053f35fde73f8da14efa828c98183b7444d5d2b3760590f679fa3dbfa81b9d5 |
|
MD5 | 7ae08f413f47857c1b938d0ece1d4182 |
|
BLAKE2b-256 | 54cc82dee0b15eade597d07732a3fff681e67d4fe543bf713e575470c7781583 |