Skip to main content

ScoreQuant

ScoreQuant is a Python library for assigning observations to a limited number of hard bins while retaining Fisher information about model parameters at a chosen reference point. It optimizes bins from scores — gradients of the log likelihood — supplied directly or computed through an explicit provider. It does not train the upstream classifier or fit the final model parameters.

CI Documentation · Walkthroughs

Install

uv add scorequant

Python 3.12 or newer. JAX and Optax are installed dependencies; NumPy is also supported for execution. Set JAX_ENABLE_X64=1 before starting Python when using JAX in double precision.

Quick start

For a Gaussian location model with unit covariance at reference mean zero, observations are already score vectors. Fit a six-bin rule on one sample and apply it to new observations:

import numpy as np
import scorequant as sq

rng = np.random.default_rng(7)
sample = sq.ScoreSample(
    rng.normal(size=(4_000, 2)),
    provenance=sq.ScoreProvenance(kind="exact", reference_point=(0.0, 0.0)),
)
fit = sq.fit_quantizer(
    sample, n_bins=6, criterion=sq.DOptimality(), config=sq.DExchangeConfig(seed=7)
)
rule = fit.quantizer
future_bins = rule.predict_scores(rng.normal(size=(1_000, 2)))
print(float(fit.train_report.geometric_mean_retention))

The printed value is empirical D-efficiency on the training sample, not a guarantee for new data. It is the geometric mean of retained-information eigenvalues, relative to the unbinned sample. Estimated scores instead yield supplied-score surrogate information; declaring provenance does not validate the score estimator.

Choose the task

Need Entry point Output
Labels for a fixed weighted sample optimize_partition(scores, ...) PartitionResult.labels; no predictor
A rule for future scores fit_quantizer(source, provider=..., ...) QuantizerResult.quantizer, with predict_scores, save and load

A ScoreSample needs no provider. Observation samples and integration sources require one; prediction keeps observation-to-score conversion explicit. Model density ratios belong to the provider; importance weights belong to the source.

DOptimality preserves information jointly across parameters. ProfiledDOptimality targets parameters of interest after profiling nuisance parameters. NormalizedTrace provides a whitened k-means baseline.

Configuration optimize_partition fit_quantizer Contract
DExchangeConfig DOptimality, ProfiledDOptimality DOptimality Exact positive-gain relocations; monotone objective; terminates exchange-stable
MahalanobisLloydConfig DOptimality, ProfiledDOptimality DOptimality A batch is adopted only if the exactly rebuilt objective improves; optional exact-exchange guard
KMeansConfig — NormalizedTrace Weighted $k$-means in whitened score space
SoftVoronoiConfig — DOptimality, ProfiledDOptimality Differentiable soft optimization then hardening, with the hardening gap reported
ScalarDPConfig — DOptimality The exact global interval solution for rank-one score space

Exchange stability is a local certificate. Global certification is a separate, budgeted D-only operation. Compiling a fixed partition into a rule requires verified D geometry; generic profiled-Ds compilation is unsupported. See the API guide for solver limits, tolerances and refusals.

Further reading

Metadata

Release files for scorequant 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 scorequant 0.3.0
File Size Uploaded Provenance Actions
scorequant-0.3.0.tar.gz 102.3 kB With provenance Details for scorequant-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 219.4 kB

Release files / scorequant-0.3.0.tar.gz

Download URL scorequant-0.3.0.tar.gz
Size 102.3 kB
Tags Source
SHA-256 checksum
How to use checksums
24a027dfd3685a7d9c261d145bfe80c3dc7773b601305639d9462fc4beb0ad70
BLAKE2b-256 checksum
How to use checksums
158254334530dbb55b71ef42e45f20a0ff596e4b22a2db5342a181cac1e88b06
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 18, 2026.

Transparency log

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

Download URL scorequant-0.3.0-py3-none-any.whl
Size 117.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95fb921a45337bdfb53b206d88475658049080b9f17ffe426637d344bd291c47
BLAKE2b-256 checksum
How to use checksums
0317458e861e92d53800438c0c385eae8c1d3f1991597e93116cf7708be57c10
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 18, 2026.

Transparency log

Security for scorequant 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for scorequant-0.3.0.tar.gz

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 18, 2026.

Transparency log

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.

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