Skip to content

Repository files navigation

CI Doc Ruff PythonVersion PyPi DOI Downloads

https://raw.githubusercontent.com/robinthibaut/skbel/main/docs/img/illu-01.png

skbel is a Python module for implementing the Bayesian Evidential Learning framework built on top of scikit-learn and is distributed under the 3-Clause BSD license.

For more information, read the documentation (latest follows the main branch) and run the example notebook.

Features

  • BEL (skbel.BEL): predictor and target reduction, canonical correlation analysis and posterior inference in mvn, kde or tm (transport map) mode, with seeded, per-row reproducible posterior sampling.
  • Calibration and scores (skbel.metrics): simulation-based calibration, PIT and interval coverage, plus CRPS, energy and Brier scores for posterior samples.
  • Ranking and acquisition (skbel.metrics): expected action losses, prospective measurement ranking and exact finite acquisition planners.
  • Design and evaluation (skbel.design, skbel.evaluation): compare measurement designs on one shared simulation bank, then score and turn posteriors into event probabilities and decision risks.
  • Optional neural posterior (skbel.neural): a Gaussian-mixture network ensemble with quantile recalibration (neural extra).
  • Experimental prediction capsules (skbel.learning.portable, skbel.learning.portable_kde): export a fitted BEL to a data-only JSON document. Capsules and the exact acquisition planners are experimental and may change.

These tools score and diagnose posteriors; they are not a guarantee. Each check addresses a specific property, so choose diagnostics that match the scope of the claim. For example, the calibration checks are marginal: draws [[-1, -1], [1, 1]] and [[-1, 1], [1, -1]] have identical target marginals and CRPS ([[0.5, 0.5]] for truth [1, 1]), but their joint energy scores differ (0.70710678 and 1.29289322).

Installation

Requires Python ≥ 3.10. Core dependencies (numpy, scipy, scikit-learn, scikit-image, pandas, matplotlib, seaborn, joblib, loguru) are installed automatically.

User installation

With pip:

pip install skbel

With uv:

uv pip install skbel

Version 2.3 is not yet available on PyPI: pip install skbel currently installs the previous release (2.1.14), which does not include the 2.3 features. To use them, install from the repository tag or from main:

pip install "git+https://github.com/robinthibaut/skbel.git@v2.3.0"

Optional extras. For 2.3, request them from the same tag source rather than from PyPI:

  • neural adds PyTorch for skbel.neural:

    pip install "skbel[neural] @ git+https://github.com/robinthibaut/skbel.git@v2.3.0"
    
  • bnn adds TensorFlow and TensorFlow Probability for skbel.bnn:

    pip install "skbel[bnn] @ git+https://github.com/robinthibaut/skbel.git@v2.3.0"
    

Quickstart

A small, deterministic fit and posterior sampling run on synthetic data:

import numpy as np
from sklearn.cross_decomposition import CCA
from sklearn.decomposition import PCA

from skbel import BEL

rng = np.random.default_rng(0)
Y = rng.normal(size=(200, 6))
X = Y @ rng.normal(size=(6, 10)) + 0.1 * rng.normal(size=(200, 10))

bel = BEL(
    mode="mvn",
    X_pre_processing=PCA(n_components=4),
    Y_pre_processing=PCA(n_components=3),
    regression_model=CCA(n_components=2),
    random_state=0,
)
bel.fit(X[:180], Y[:180])
samples = bel.predict(X[180:181], n_posts=50)
print(samples.shape)  # (1, 50, 6): observations, posterior draws, target size

Repeated calls with the same random_state return the same samples. The design, evaluation, learning and metrics subpackages are also available as skbel.design and so on, and through from skbel import *.

Development

We welcome new contributors of all experience levels.

Important links

Source code

You can check the latest sources with the command:

git clone https://github.com/robinthibaut/skbel.git

Contributing

Contributors and feedback from users are welcome. Don't hesitate to submit an issue or a PR, or request a new feature.

A pull request that changes user-facing behavior also updates the Unreleased section of the changelog, this README and the linked documentation, as listed in the pull request template. The release checklist is in RELEASING.md (also in the documentation). A release is complete only when it is on PyPI, its exact Zenodo version DOI is recorded in both the README citation and CITATION.cff, and the stable documentation build shows it.

Testing

Clone the repo and run the test suite with uv:

git clone https://github.com/robinthibaut/skbel.git
cd skbel
uv sync --extra dev
uv run pytest

To run a single test:

uv run pytest skbel/testing/test_basic.py::test_mvn

The reference arrays under skbel/testing/ are kept in the source checkout and source distribution but are not installed with the wheel. They are deterministic outputs of the fixed BEL pipeline. If a future scikit-learn or scipy release shifts the canonical-correlation sign convention or numerical kernels enough to break the regression checks, regenerate them with:

uv run python scripts/regenerate_test_references.py

Help and Support

Documentation

Communication

How to cite

Thibaut, Robin, & Maximilian Ramgraber. (2026). SKBEL - Bayesian Evidential Learning framework built on top of scikit-learn (v2.3.0). Zenodo. https://doi.org/10.5281/zenodo.23290084

BibTeX:

@software{thibaut_skbel,
author       = {Thibaut, Robin and Ramgraber, Maximilian},
title        = {{SKBEL} - Bayesian Evidential Learning framework built on top of scikit-learn},
month        = oct,
year         = 2026,
publisher    = {Zenodo},
version      = {2.3.0},
doi          = {10.5281/zenodo.23290084},
url          = {https://doi.org/10.5281/zenodo.23290084},
}

The DOI above, 10.5281/zenodo.23290084, is the Zenodo version DOI of v2.3.0. The Zenodo concept DOI, 10.5281/zenodo.4785144, represents all versions of SKBEL and always resolves to the latest one. See also the citation page.

Notebooks and tutorials

Nolwenn Lesparre, Nicolas Compaire, Thomas Hermans and Robin Thibaut. (2022). 4D Temperature Monitoring with BEL. [Dataset]. Kaggle. doi: 10.34740/kaggle/ds/2275519. url: https://doi.org/10.34740/kaggle/ds/2275519

Thibaut, Robin (2021). WHPA Prediction. [Dataset]. Kaggle. doi:10.34740/kaggle/dsv/2648718. url: https://www.kaggle.com/dsv/2648718

Peer-reviewed publications using SKBEL

Thibaut, Robin, Nicolas Compaire, Nolwenn Lesparre, Maximilian Ramgraber, Eric Laloy, and Thomas Hermans (Nov. 2022). “Comparing Well and Geophysical Data for Temperature Monitoring Within a Bayesian Experimental Design Framework”. In: Water Resources Research 58 (11). issn: 0043-1397. doi: 10.1029/2022WR033045. url: https://onlinelibrary.wiley.com/doi/10.1029/2022WR033045.

Thibaut, Robin, Eric Laloy, and Thomas Hermans (Dec. 2021). “A new framework for experimental design using Bayesian Evidential Learning: The case of wellhead protection area”. In: Journal of Hydrology 603, p. 126903. issn: 00221694. doi: 10.1016/j.jhydrol.2021.126903. url: https://linkinghub.elsevier.com/retrieve/pii/S0022169421009537.