Grammar-first generalized linear modeling in JAX.
Project description
glmax
Grammar-first generalized linear modeling in JAX. JIT-compiled end-to-end and differentiable through the fitted parameters via the implicit function theorem.
Example
import jax.numpy as jnp
import glmax
X = jnp.array([[1.0, 0.5], [1.0, -0.3], [1.0, 1.2], [1.0, -0.8]])
y = jnp.array([2.0, 1.0, 4.0, 1.0])
fitted = glmax.fit(glmax.Poisson(), X, y)
pred = glmax.predict(fitted.family, fitted.params, X)
result = glmax.infer(fitted)
diag = glmax.check(fitted)
Four verbs — fit, predict, infer, and check — cover the full modeling workflow. Each takes explicit inputs and returns an explicit result. No hidden state is threaded between calls.
predict returns response-scale fitted means, matching fitted.mu.
See the docs for the full API reference and guides.
Installation
For the latest release:
pip install glmax
For the latest repository state:
pip install git+https://github.com/mancusolab/glmax.git
Performance
Benchmarked against statsmodels on Poisson regression. Timing uses 10 steady-state runs after JIT warm-up. Statsmodels does not support GPU/TPU natively, and all reported runtimes are CPU-based, however the colab environment has different host CPUs depending on the runtime selected. As such we report the native CPU runtimes for statsmodels for each runtime environment.
| n | p | statsmodels (ms) | glmax (ms) | speedup | runtime |
|---|---|---|---|---|---|
| 500 | 10 | 4.32 | 0.92 | 4.7× | CPU |
| 2,000 | 20 | 277.76 | 4.14 | 67.1× | CPU |
| 10,000 | 50 | 1428.76 | 42.77 | 33.4× | CPU |
| 500 | 10 | 2.97 | 3.00 | 1.0× | T4 GPU |
| 2,000 | 20 | 13.94 | 4.38 | 3.2× | T4 GPU |
| 10,000 | 50 | 212.70 | 17.94 | 11.9× | T4 GPU |
| 500 | 10 | 1.90 | 2.89 | 0.7× | v5e-1 TPU |
| 2,000 | 20 | 8.46 | 8.80 | 1.0× | v5e-1 TPU |
| 10,000 | 50 | 1220.66 | 25.65 | 47.6× | v5e-1 TPU |
See examples/benchmark_colab.ipynb for the full benchmark notebook.
Testing
pytest -p no:capture tests
Notes
glmax was developed by members of the Mancuso Lab with assistance from
Claude Code and Codex, following the practices described in the
scientific-software-playbook.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glmax-0.1.1.tar.gz.
File metadata
- Download URL: glmax-0.1.1.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2fac4640bb05779fae2c49fb4ca55ef4c6086de925df010172c5d04a4a6f63a
|
|
| MD5 |
71fdb5c2c1109887df4b97f4accadb2f
|
|
| BLAKE2b-256 |
5248a69bbb774e60fb59cd861f83b0ce08fa577cbbde72fdf13527dc2078c8a5
|
Provenance
The following attestation bundles were made for glmax-0.1.1.tar.gz:
Publisher:
release.yml on mancusolab/glmax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glmax-0.1.1.tar.gz -
Subject digest:
d2fac4640bb05779fae2c49fb4ca55ef4c6086de925df010172c5d04a4a6f63a - Sigstore transparency entry: 1862399214
- Sigstore integration time:
-
Permalink:
mancusolab/glmax@8a45dcc9c24eeda3f6bd1cf4e1fd09445e6af57d -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mancusolab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8a45dcc9c24eeda3f6bd1cf4e1fd09445e6af57d -
Trigger Event:
release
-
Statement type:
File details
Details for the file glmax-0.1.1-py3-none-any.whl.
File metadata
- Download URL: glmax-0.1.1-py3-none-any.whl
- Upload date:
- Size: 39.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80d9299d5a15ed4c0ea3a11acb90204cc65c753a9c8c68d3cffa327aa1d4f9e0
|
|
| MD5 |
9d8ffb8704c88702bbd79e3456765378
|
|
| BLAKE2b-256 |
41f3918ccf4d97d19e51105c8f320c8211f31a67cd343571c554cf973d76b88f
|
Provenance
The following attestation bundles were made for glmax-0.1.1-py3-none-any.whl:
Publisher:
release.yml on mancusolab/glmax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glmax-0.1.1-py3-none-any.whl -
Subject digest:
80d9299d5a15ed4c0ea3a11acb90204cc65c753a9c8c68d3cffa327aa1d4f9e0 - Sigstore transparency entry: 1862399375
- Sigstore integration time:
-
Permalink:
mancusolab/glmax@8a45dcc9c24eeda3f6bd1cf4e1fd09445e6af57d -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mancusolab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8a45dcc9c24eeda3f6bd1cf4e1fd09445e6af57d -
Trigger Event:
release
-
Statement type: