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.3.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.3.0
File Size Uploaded
stagereg-0.3.0.tar.gz 175.8 kB Details

Built distribution (wheel)

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

Total release size: 273.2 kB

Release files / stagereg-0.3.0.tar.gz

Download URL stagereg-0.3.0.tar.gz
Size 175.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c79dd2270d64d794c8d53e699f4eea36a34ddb01c7dbcececbefcaeb6cd718a2
BLAKE2b-256 checksum
How to use checksums
bb66626ac00e8f28aa149377989debbb8fc7e203d6c8217023dc6609dee39700
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 19, 2026.

Transparency log

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

Download URL stagereg-0.3.0-py3-none-any.whl
Size 97.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6895065534325ee9754eea4be5bfc49a0d9e80cac0d223a1f782addac0037f89
BLAKE2b-256 checksum
How to use checksums
8c0ffc8c0481db84e25c33ff6ef9c1d0af87fa326f60ee2bc635640a9a9c94a7
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 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.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