Skip to main content

stagereg

PyPI version Python versions License: BSD-3-Clause

stagereg is a library for stage-oriented probabilistic regression: training models that predict a distribution over the target, not just a point estimate. Training runs as a sequence of explicit, checkpointed stages, such as fitting a mean model and then a separate variance model on its residuals. A core of backend-neutral contracts is implemented by an optional JAX backend built on Flax NNX and Optax.

Documentation: https://groupisp.github.io/stagereg/

Install

Install with the JAX backend (JAX, Flax and Optax):

pip install "stagereg[jax]"

The optional plot extra also installs matplotlib, for plotting results:

pip install "stagereg[jax,plot]"

With uv, use the equivalent uv add form:

uv add "stagereg[jax]"
uv add "stagereg[jax,plot]"

Drop the [jax] extra for the backend-neutral contracts alone, which depend only on NumPy.

The documentation tracks the main branch, with no per-release docs before 1.0, so it may describe features newer than your installed version.

Minimal example

Fit a linear model to y = 3x + 2 for a fixed number of epochs with the JAX backend:

import jax
import jax.numpy as jnp
import optax
from flax import nnx

from stagereg.core.types import Batch
from stagereg.jax import create_optimizer, initialize_training_state, run_supervised


def squared_error(model, inputs, targets, sample_weight, key, training):
    return jnp.mean(jnp.square(model(inputs) - targets))


inputs = jnp.linspace(-1.0, 1.0, 32).reshape(-1, 1)
targets = 3.0 * inputs + 2.0


def loader(*, split, epoch):
    return [Batch(inputs=inputs, targets=targets)]


model = nnx.Linear(1, 1, rngs=nnx.Rngs(0))
optimizer = create_optimizer(model, optax.sgd(learning_rate=0.1))
state = initialize_training_state(model, optimizer, rng_key=jax.random.key(0))

result = run_supervised(
    model=model,
    optimizer=optimizer,
    train_loader=loader,
    loss=squared_error,
    state=state,
    epochs=3,
)
print(f"final training loss: {result.loss:.4f}")

Metadata

Release files for stagereg 0.1.0

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

Source distribution (sdist)

Source distribution for stagereg 0.1.0
File Size Uploaded
stagereg-0.1.0.tar.gz 139.0 kB Details

Built distribution (wheel)

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

Total release size: 218.1 kB

Release files / stagereg-0.1.0.tar.gz

Download URL stagereg-0.1.0.tar.gz
Size 139.0 kB
Tags Source
SHA-256 checksum
How to use checksums
10381daccb63923632b6e6b2195a29a2c47f3c391acb9d7e8b1d52a067792275
BLAKE2b-256 checksum
How to use checksums
adec4239dc6e24afa5300bd9f4c14b78cd23e35f0cbadeca96b4309628cd7e7f
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 Oct 12, 2026.

Transparency log

Release files / stagereg-0.1.0-py3-none-any.whl

Download URL stagereg-0.1.0-py3-none-any.whl
Size 79.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf97fdf551e40d0b600b1ecbd8cae83de53fd48aaa82e1119bcebeaa991a6510
BLAKE2b-256 checksum
How to use checksums
ee608dc4c4389d90ad83ede47f2df6e6bee799cfb01bb6d453f88e7cdd8c82c6
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 Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

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