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).
Table of contents
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:
- notebooks/1. Factors.ipynb
- notebooks/2. Bags of factors.ipynb
- notebooks/3. Conditional probability tables.ipynb
- notebooks/4. Bayesian Networks.ipynb
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 .
Metadata
Release files for thomas-core 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| thomas-core-0.1.3.tar.gz | 98.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thomas_core-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 206.5 kB
Release files / thomas-core-0.1.3.tar.gz
| Download URL | thomas-core-0.1.3.tar.gz |
|---|---|
| Size | 98.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e87354eaab0026c950c140b429a4bbb3049a3860ca9420842fd30cc30ff179b9
|
|
BLAKE2b-256 checksum How to use checksums |
7fc6b2467b4a1c13af36f3e85f4832739988010eef71bee46fe5df0304a60d41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
|
Release files / thomas_core-0.1.3-py3-none-any.whl
| Download URL | thomas_core-0.1.3-py3-none-any.whl |
|---|---|
| Size | 108.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d991868454f35e5c5cdc18229af5128904b6b4d2dd50ef67295b3ec2aea5e1e9
|
|
BLAKE2b-256 checksum How to use checksums |
7bccf1a7cf81d288cffe21658a9317731c984511c950ef4c38ee256d65ce4076
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
|
Security for thomas-core 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.