Repository structure¶
This repository is organised into the following main components.
Core library (tbnpy/)¶
The tbnpy directory contains the core implementation of the
tensor-based Bayesian network (TBN) framework.
It is designed to be compatible with matrix-based Bayesian networks
through the mbnpy module, especially for discrete variables.
Defining a model:
variable.py: Variable definitionsprobability.py: The probability-object protocol, the optionalProbabilitybase class, andcheck_modelcpt.py: Conditional probability tensorsspec.py: A model written as data (JSON), validatedcompile.py: Compiles a spec into variables and probability objectsexpr.py: The expression language of specs
Running and checking it:
inference.py: Inference routinesadaptiveMH.py: Adaptive Metropolis–Hastings samplerdiagnostics.py: Prior sense checks, evidence validation and weighted posteriors
For scalable Bayesian network inference, TBN performs tensorised operations that generate many Monte Carlo samples simultaneously.
Examples (examples/)¶
Runnable, self-contained experiments demonstrating full workflows.
ABCDE/: Minimal mixed-variable Bayesian network, as classes and as a spec (abcde.tbn.json)EMA_aftershock/: Mainshock-aftershock analysis of the Eastern Massachusetts highway network… (additional example directories)
Tests (tests/)¶
python -m pytest tests runs the test suite.