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

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.2
File Size Uploaded Provenance Actions
tbnpy-0.3.2.tar.gz 78.4 kB Without provenance Details for tbnpy-0.3.2.tar.gz

Built distribution (wheel)

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

Total release size: 138.3 kB

Release files / tbnpy-0.3.2.tar.gz

Download URL tbnpy-0.3.2.tar.gz
Size 78.4 kB
Tags Source
SHA-256 checksum
How to use checksums
87a6f1faf509ea8f0b91193b4dc8e935148b700588700fe0870c4f9bc4d0231b
BLAKE2b-256 checksum
How to use checksums
2043f36e2d8ecdb534f62835d9bd9b6cabdd939e93c0becea256137d1de16412
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.2-py3-none-any.whl

Download URL tbnpy-0.3.2-py3-none-any.whl
Size 59.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
939e6ff0d55a351e294bdf82870874e4168c36fff86a3a4e326d401433d40ce4
BLAKE2b-256 checksum
How to use checksums
7a9972bfde1afb7cce680726729664b01857e5061c4e5f89763d35e94bebfb88
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.2

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