Skip to main content

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.

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tbnpy 0.3.0
File Size Uploaded Provenance Actions
tbnpy-0.3.0.tar.gz 76.7 kB Without provenance Details for tbnpy-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tbnpy 0.3.0
File Interpreter ABI Platform Actions
tbnpy-0.3.0-py3-none-any.whl Python 3 none any Details for tbnpy-0.3.0-py3-none-any.whl

Total release size: 136.2 kB

Release files / tbnpy-0.3.0.tar.gz

Download URL tbnpy-0.3.0.tar.gz
Size 76.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0c18eb22fc332085ad7999d25bff4c2d48a92f3b75c9227ba7a5fc36c58de56f
BLAKE2b-256 checksum
How to use checksums
eac0cd6d84970f5b9d9102d8adab2571f5d1c9c203659f07cdde425bb480f109
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / tbnpy-0.3.0-py3-none-any.whl

Download URL tbnpy-0.3.0-py3-none-any.whl
Size 59.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d197ca99df03fc07418d80f73ff6bba7f18146e8a9eda5bdb11c0b5a8cc026bd
BLAKE2b-256 checksum
How to use checksums
dcd102b303661b562022691c5573d6c86f76bd85ccc7e073f6447db405a9b24f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for tbnpy 0.3.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page