gp3bayespy
Contract-first Bayesian workflows for hierarchical behavioural data in Python
Documentation · PyPI · Examples · Articles · Migration guide · Release v0.6.1 · Archived v0.5.0 DOI
gp3bayespy is the Python port of the R package gp3bayes. It provides governed Bayesian workflows for repeated-measures and hierarchical behavioural data, with first-class support for model contracts, posterior and predictive diagnostics, sensitivity analysis, PSIS-LOO model comparison, reproducibility, and dynamic pupillometry.
Version 0.5.0 is the first public Python release frozen against gp3bayes 0.5.0.
Version 0.6.1 adds contract-first Bayesian multilevel gaze mediation while preserving the frozen gp3bayes 0.5.0 parity baseline.
v0.6.0 is retained only as a withdrawn GitHub audit release; it was never published to PyPI.
Why gp3bayespy?
| Capability | What it provides |
|---|---|
| Contract-first modelling | Explicit outcome, grouping, condition, prior, model-family, and analysis contracts before fitting. |
| Hierarchical Bayesian workflows | Binary and positive lognormal-duration simulation, preparation, fitting, prediction, PPC, recovery, and reporting. |
| Posterior & predictive validation | Sampler diagnostics, calibration, scoring, uncertainty summaries, PSIS-LOO, influence diagnostics, and model comparison. |
| Sensitivity & robustness | Prior-scale sensitivity, power-scaling, group deletion, alternative estimands, SBC, and recovery diagnostics. |
| Dynamic pupillometry | Baseline/gaze/luminance sensitivity, time-course models, temporal diagnostics, binocular models, GP trajectories, robust/distributional models, and missing-data workflows. |
| Reproducible evidence | Analysis manifests, model cards, publication bundles, evidence inventories, registries, dashboards, and transformation replay. |
| Governed outputs | No automatic model selection, participant exclusion, adequacy declaration, causal claim, or psychological-state inference. |
Installation
Core
python -m pip install gp3bayespy
Bayesian backends and plotting
python -m pip install "gp3bayespy[bayes,plots]"
Complete environment
python -m pip install "gp3bayespy[all]"
The core installation contains NumPy, pandas, and SciPy workflows. PyMC, CmdStanPy, ArviZ/xarray, and Matplotlib are optional and installed through the corresponding extras.
Quick start
import pandas as pd
from gp3bayespy import (
audit_model_readiness,
create_model_contract,
create_model_specification,
create_prior_specification,
)
data = pd.DataFrame(
{
"participant_id": ["p1"] * 4 + ["p2"] * 4,
"trial_id": [1, 2, 3, 4] * 2,
"condition": ["control", "treatment"] * 4,
"selected": [0, 1, 0, 1, 1, 0, 1, 0],
}
)
contract = create_model_contract(
family="binary",
outcome_col="selected",
participant_col="participant_id",
trial_col="trial_id",
condition_col="condition",
)
audit = audit_model_readiness(data, contract)
priors = create_prior_specification(contract, baseline=0.5)
specification = create_model_specification(contract, audit, priors)
print(specification.formula_text)
The package separates data readiness, prior declaration, model specification, fitting, diagnostics, estimands, and sensitivity rather than hiding those decisions inside a single convenience call.
Workflow map
| Goal | Start with |
|---|---|
| Model trial-level gaze mediation | examples/multilevel_gaze_mediation_contract.py · workflow |
| Build a binary hierarchical workflow | examples/binary_workflow.py · article |
| Build a duration workflow | examples/duration_workflow.py · article |
| Inspect posterior/predictive diagnostics | examples/predictive_diagnostics.py · article |
| Compare models with PSIS-LOO | examples/loo_model_comparison.py · article |
| Run sensitivity analyses | examples/sensitivity_workflow.py · article |
| Analyse pupil time courses | examples/pupil_workflow.py · pupillometry articles |
| Record reproducible analysis state | examples/reproducibility_workflow.py · article |
| Check optional backend status | examples/backend_status.py · backend guide |
Documentation
The documentation site is the primary user guide:
- Getting started — package orientation and first workflow.
- API reference — public Python API.
- 59 articles — Python-facing ports of the canonical gp3bayes vignettes.
- Executable examples — thirteen executable scripts spanning the core and mediation workflows.
- Plot gallery — publication-oriented plotting workflows.
- Migration guide — R-to-Python mapping for gp3bayes users.
Parity and validation
The 0.5.0 release is frozen against the CRAN source archive gp3bayes_0.5.0.tar.gz.
| Validation item | Release state |
|---|---|
| Frozen R exports | 458 / 458 implemented |
| Canonical articles | 59 / 59 ported |
Public unrestricted **kwargs |
0 |
| Released v0.5.0 test suite | 321 / 321 passing |
| Released v0.6.1 validation suite | 731 passed / 1 skipped |
| Released v0.5.0 branch-aware coverage | 47.9482% |
v0.6.1 / current main branch-aware coverage |
100.00% |
| v0.6.1 statements / branches | 12,872 / 4,210, all covered |
Current main coverage exclusions |
0 |
| Source examples | 13 / 13 |
| Clean wheel / sdist installation | PASS / PASS |
| Ruff / mypy | PASS / PASS |
| Linux / macOS / Windows CI | PASS |
| Strict documentation build | PASS |
The machine-readable parity ledger is dev/parity/function_map.csv, the article map is dev/parity/articles.json, and the final freeze record is dev/parity/final_deep_freeze_0.5.0.json.
Frozen R reference details
The reference archive contains 458 public exports, 230 S3 registrations, 60 R source files, 465 Rd help files, 59 vignette sources, and 54 tests/testthat/test-*.R files plus the package-level runner.
Reference archive SHA-256:
537eb05f949de1bcc1d6f8234066f064597951ecfa9cbbdf938d0a895ce5dd8a
Governance
gp3bayespy intentionally separates statistical evidence from analyst conclusions. Creating or fitting a model does not automatically establish convergence, model adequacy, causal identification, robustness, a preferred model, participant/group exclusion, or psychological/cognitive/emotional interpretation.
Automatic-selection and automatic-adequacy fields remain explicit and conservative where relevant.
Citation
If you use gp3bayespy, cite the archived software record for the version you used. The DOI for gp3bayespy 0.5.0 is 10.5281/zenodo.22150746. Repository citation metadata are provided in CITATION.cff. Cite the gp3bayes R reference where it is methodologically relevant.
License
MIT License. See LICENSE.
October 2026 research article and figure
Pupil visual covariates and Bayesian qualification documents experimental, source-only validation methods and reproducible synthetic examples. It is available in the website navigation, while independently qualified external empirical claims and stable PyPI APIs remain separate (scientific acceptance criteria).
Metadata
Release files for gp3bayespy 0.6.2
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 | |
|---|---|---|---|---|
| gp3bayespy-0.6.2.tar.gz | 441.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gp3bayespy-0.6.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 710.2 kB
Release files / gp3bayespy-0.6.2.tar.gz
| Download URL | gp3bayespy-0.6.2.tar.gz |
|---|---|
| Size | 441.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
193d65e2223f5b007c663e924d47261c9cdfc60e5abbe51fbebaab6a1116e8dc
|
|
BLAKE2b-256 checksum How to use checksums |
0304ada5280fa94ec6ea8655b863eec04c4dac7ca39b98b6dd028cb9368b4375
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / gp3bayespy-0.6.2-py3-none-any.whl
| Download URL | gp3bayespy-0.6.2-py3-none-any.whl |
|---|---|
| Size | 268.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27eacc5825d646080a0806f84b389dd212fa58abce896bedeed82a53b06f3169
|
|
BLAKE2b-256 checksum How to use checksums |
bb3bd47fcaee42cc742c7ebed5269b7adce4b732c99f224a54d3e1a032bb3730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for gp3bayespy 0.6.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for gp3bayespy-0.6.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA 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.