Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glmax-0.1.1.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glmax-0.1.1-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

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

Hashes for glmax-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d2fac4640bb05779fae2c49fb4ca55ef4c6086de925df010172c5d04a4a6f63a
MD5 71fdb5c2c1109887df4b97f4accadb2f
BLAKE2b-256 5248a69bbb774e60fb59cd861f83b0ce08fa577cbbde72fdf13527dc2078c8a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for glmax-0.1.1.tar.gz:

Publisher: release.yml on mancusolab/glmax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for glmax-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80d9299d5a15ed4c0ea3a11acb90204cc65c753a9c8c68d3cffa327aa1d4f9e0
MD5 9d8ffb8704c88702bbd79e3456765378
BLAKE2b-256 41f3918ccf4d97d19e51105c8f320c8211f31a67cd343571c554cf973d76b88f

See more details on using hashes here.

Provenance

The following attestation bundles were made for glmax-0.1.1-py3-none-any.whl:

Publisher: release.yml on mancusolab/glmax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page