Skip to main content
Python Suite research packages logo

gp3bayespy

Contract-first Bayesian workflows for hierarchical behavioural data in Python

PyPI Python CI Docs License: MIT R reference Archived v0.5.0 DOI

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
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:

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
0.6.0 release test suite 689 / 689 passing
Released v0.5.0 branch-aware coverage 47.9482%
Current main branch-aware coverage 100.00%
Current main coverage exclusions 0
Source examples 8 / 8
Installed-wheel examples 8 / 8
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.

Metadata

Release files for gp3bayespy 0.6.1

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

Source distribution (sdist)

Source distribution for gp3bayespy 0.6.1
File Size Uploaded
gp3bayespy-0.6.1.tar.gz 440.5 kB Details

Built distribution (wheel)

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

Total release size: 708.6 kB

Release files / gp3bayespy-0.6.1.tar.gz

Download URL gp3bayespy-0.6.1.tar.gz
Size 440.5 kB
Tags Source
SHA-256 checksum
How to use checksums
218654233cb10f8432e3c5ac27bb98363c8aa63d791388989811db9f3a093780
BLAKE2b-256 checksum
How to use checksums
f56ef9c4e5fbbcfc6dda13435e08fc238e16e41b6eb99491f85438628b72b30f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 21, 2026.

Transparency log

Release files / gp3bayespy-0.6.1-py3-none-any.whl

Download URL gp3bayespy-0.6.1-py3-none-any.whl
Size 268.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06bf7aa70169892c30c3bb5600c18554d3132c2983470ac753a33e4f34821849
BLAKE2b-256 checksum
How to use checksums
7236c6fe6d0b0805329296bced2c1ed17d2acac7fbe7f3bed1ca023a3a2ae5f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.5.0

2 release files

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