birm: Bayesian Impulse-Response Modeling
About
This package implements a Bayesian Impulse-Response Model (BIRM) for athletic performance. The default prior structure is physiologically informed and resolves inference issues common in the literature, and the model allows for multivariate inputs and outputs so that parameters can be informed by multiple metrics of performance adjusted for their external influencers.
Usage
Installation
Install from PyPI:
pip install birm
Preparing data
The Panel is the model-ready dataset used by birm to align loads, metrics and exogenous
predictors. Build a Panel from a single long-form table:
import pandas as pd
from birm import Panel
df = pd.DataFrame(
{
"date": ["2025-01-03", "2025-01-03", "2025-01-04", "2025-01-06"],
"metric": ["w", "hrv", "hrv", "speed"],
"value": [210.0, 64.0, 61.0, 4.71],
}
)
panel = Panel.from_long(df, date="date", metric="metric", value="value", load="w").standardize()
panel.T # 4 days on the shared daily grid
panel.densest() # 'hrv' has the most observations
See the docs for more ways to build the Panel from
your data.
Specifying a model
An IRModel is the declarative spec of the shared-stock impulse-response model. You define it by
picking a fitness × fatigue core and attach one Metric per response series, then fit it with
.fit(panel).
from birm import IRModel, Load, Metric
model = IRModel(
load=Load("w"), # training-load driver w_t
fitness="banister",
fatigue="banister", # selects the impulse-response core R_t
metrics=(
Metric("hrv", exog=("w",), ar1=True), # HRV-suppression beta + slow drift u
Metric("speed", exog=("temp", "indoor")), # heat + treadmill adjustments
),
)
idata = model.fit(panel, sampler=dict(draws=1000, tune=2000, seed=0))
idata is an ArviZ InferenceData. Summarize parameters, check convergence, or pull the
shared impulse-response stock R_t:
import arviz as az
az.summary(idata, var_names=["k_F", "k_G", "tau_F", "tau_G"], ci_prob=0.95) # mean, 95% CI, r_hat
az.plot_trace(idata, var_names=["k_F", "tau_F"]) # convergence diagnostics
R = idata.posterior["R"] # (chain, draw, T) latent stock
R_mean = R.mean(("chain", "draw")) # posterior-mean trajectory
idata.to_netcdf("fit.nc") # cache for later reuse
See the docs for the full model reference.
For Developers
Setup
uv sync # install package + dev dependencies into .venv
Development workflow
All changes should be made on a branch and merged to main via pull request. All changes require
accompanying unit tests in tests/ and documentation in docs/.
git checkout -b feat/my-feature # or fix/, docs/, refactor/, etc.
# ...you make your changes, and then
make format # auto-fix formatting and lint violations
make check # lint, type-check, and verify docstring coverage
make test # run tests with coverage (90% minimum)
make docs-serve # preview docs locally at http://127.0.0.1:8000
git push -u origin feat/my-feature
# open a pull request on GitHub
CI runs make check and make test automatically on every push and pull request. A PR cannot be merged if CI fails.
What triggers what
| Action | CI checks | Docs deployed | Package published |
|---|---|---|---|
| Push to any branch / open PR | ✓ | ||
Merge to main |
✓ | ✓ | |
Push a v* tag |
✓ |
Docs-only change (e.g. fix a typo in docs/ or a docstring): open a PR and merge to main. Docs redeploy automatically, no tag needed.
Code-only change (e.g. bug fix): merge to main, then tag when ready to publish (see below). Docs will also redeploy on merge, reflecting any updated docstrings.
Publishing a new package version
- Bump the version in
pyproject.toml:# choose one: make bump-patch # 0.1.0 → 0.1.1 (bug fixes) make bump-minor # 0.1.0 → 0.2.0 (new features) make bump-major # 0.1.0 → 1.0.0 (breaking changes)
- Commit, tag, and push:
git add pyproject.toml git commit -m "chore: bump version to v0.x.x" git tag v0.x.x git push && git push --tags
Pushing the tag triggers the publish workflow, which runs the test suite and publishes the package to PyPI. Check that the release appeared:
- Package: https://pypi.org/project/birm/
- Docs: https://hrmerrill.github.io/birm/
Metadata
Release files for birm 0.1.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 | Actions |
|---|---|---|---|---|
| birm-0.1.2.tar.gz | 23.3 kB | Without provenance | Details for birm-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| birm-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for birm-0.1.2-py3-none-any.whl |
Total release size: 50.7 kB
Release files / birm-0.1.2.tar.gz
| Download URL | birm-0.1.2.tar.gz |
|---|---|
| Size | 23.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60d8d2635ad7e8191a3fe0cde7bd9b9e92cf580947ea3d8b89d0c197aaefe476
|
|
BLAKE2b-256 checksum How to use checksums |
8d1f73529f98f3db0599f95e52d20f4f5d3380bb848479db2331d61b2b4b7f4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / birm-0.1.2-py3-none-any.whl
| Download URL | birm-0.1.2-py3-none-any.whl |
|---|---|
| Size | 27.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5d55759af6ac99cffdbb1f86fb34dd9484713a7a5ccf72e45b5c4a123a06dec
|
|
BLAKE2b-256 checksum How to use checksums |
7311875d50853c37a3256058ad7ff6ab1d48a0dfa8dddb566bda9c0f503450b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for birm 0.1.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.