tbnpy
tbnpy is a Python toolkit for tensor-based Bayesian networks (TBNs), designed for scalable probabilistic inference in systems with large, structured state spaces.
It is particularly suited to applications where classical Bayesian network implementations struggle due to combinatorial growth in system states.
The package provides:
- A tensor-based formulation of Bayesian networks
- Scalable exact and approximate inference algorithms
- Support for hybrid discrete–continuous models
- Reusable system-level rules and probabilistic components
- Examples illustrating end-to-end modelling and inference workflows
Documentation
📘 Full documentation is available here:
👉 https://jieunbyun.github.io/tbnpy/
The online documentation includes:
- Conceptual overview of tensor-based Bayesian networks
- Installation and getting-started guides
- API reference for all core modules
- Worked examples (including the ABCDE example)
- Repository structure and design rationale
A first look
import tbnpy
from tbnpy.compile import compile_file
spec, varis, probs = compile_file("examples/ABCDE/abcde.tbn.json")
probs["C"] # DistributionSpecNode(P(C | A, B): normal(loc=A + B, scale=0.6))
print(probs["C"]) # each variable with its domain
print(tbnpy.check_model(probs)) # every object keeps the protocol: no problems found
A probability object is any class with childs, parents, sample and log_prob.
Inheriting tbnpy.Probability is optional and makes it print as above. What changed
in each version is in CHANGELOG.md.
Repository structure
tbnpy/
├── tbnpy/ # Core library
├── examples/ # Worked examples and case studies
├── docs/ # Sphinx documentation source
├── .github/ # CI/CD workflows (GitHub Actions)
└── README.md
Installation
tbnpy can be installed either as a released package from PyPI or in editable (developer) mode from the source repository.
Using pip (recommended for users)
Install the latest released version from PyPI:
pip install tbnpy
This installs a stable version of the tools suitable for general use.
Verify the installation:
python -c "import tbnpy; print(tbnpy.__version__)"
Using pip (editable / developer install)
If you are developing tbnpy or working directly with the source code,
install in editable mode from the repository root:
# Activate your environment first (if using conda)
conda activate <your-env>
# Install in editable mode
pip install -e .
Development status
tbnpy is under active development.
The API may evolve as new modelling patterns, inference strategies, and large-scale case studies are incorporated.
Releasing
The version is written once, in tbnpy/__init__.py. To release, update it and
CHANGELOG.md, commit, then push a tag of the same version:
git tag v0.3.0
git push origin v0.3.0
The release workflow runs the tests, checks that the tag matches the version, builds
the package from the tagged commit, and publishes it to PyPI. Running the workflow by
hand (Actions, then Run workflow) publishes to TestPyPI instead, for a rehearsal.
Citation
A dedicated tbnpy methodology paper is currently under preparation.
In the meantime, please cite the following related work:
Byun, J.-E., & Song, J. (2021). Generalized matrix-based Bayesian network for multi-state systems. Reliability Engineering & System Safety, 211, 107468.
License
This project is released under an MIT license.
See the repository for license details.
For detailed usage, examples, and API documentation, please refer to:
🔗 https://jieunbyun.github.io/tbnpy/
Metadata
Release files for tbnpy 0.3.1
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 | Actions |
|---|---|---|---|---|
| tbnpy-0.3.1.tar.gz | 78.5 kB | Without provenance | Details for tbnpy-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tbnpy-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for tbnpy-0.3.1-py3-none-any.whl |
Total release size: 138.5 kB
Release files / tbnpy-0.3.1.tar.gz
| Download URL | tbnpy-0.3.1.tar.gz |
|---|---|
| Size | 78.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42b515b1560fe5051b7bc9d46453666b96067bb956c8c034ece08af89ce72558
|
|
BLAKE2b-256 checksum How to use checksums |
0031e9f7622b79f43732f2e111dde574a7f525b7b45b27afcc77ba90f3ab4ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Release files / tbnpy-0.3.1-py3-none-any.whl
| Download URL | tbnpy-0.3.1-py3-none-any.whl |
|---|---|
| Size | 60.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee128183f959846cfeeffe135bc2093f1009b784bffe83470314f1f711984f07
|
|
BLAKE2b-256 checksum How to use checksums |
eb7dddf8e04b7db2568acb218b8c40de186b2ce1d7b0b4523c653f1c60d6c56a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Security for tbnpy 0.3.1
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.