CalibRoute
CalibRoute is a lightweight Python toolkit for confidence evaluation and
uncertainty-aware routing. It converts model predictions into three actions:
accept, human_review, or abstain.
Features
- Confidence calibration and error-ranking metrics
- Risk-coverage analysis
- Validation-only threshold fitting
- Tie-aware threshold fitting and independent holdout risk assessment
- Batch-size-aware confidence-shift detection
- Financial NER encoder and generative-output adapter
- CSV and JSONL support
- Dependency-free Python API and CLI
Install
Requires Python 3.10 or newer.
Install with python -m pip install calibroute-ai.
To run the checked-in examples or contribute, clone the repository:
git clone https://github.com/Garyouki/calibroute.git
cd calibroute
python -m pip install -e .
The distribution name is calibroute-ai; the Python import and command are
calibroute. No API key or model service is needed.
Quick start
# Audit labeled predictions
calibroute audit \
--input examples/validation.csv \
--output examples/audit.md
# Fit an acceptance policy on validation data
calibroute fit \
--input examples/validation.csv \
--max-risk 0.20 \
--min-coverage 0.25 \
--risk-method empirical \
--output examples/policy.json
# Route a new prediction batch
calibroute route \
--input examples/production_batch.csv \
--policy examples/policy.json \
--output examples/decisions.csv \
--summary examples/routing-summary.json
Input format
| Field | Required | Description |
|---|---|---|
id |
recommended | Prediction identifier |
confidence |
yes | Number between 0 and 1 |
correct |
audit and fit only |
Boolean or 1/0 label |
domain |
no | Evaluation slice or deployment domain |
Additional columns are preserved as metadata.
The default fit searches thresholds using pointwise 95% Clopper-Pearson bounds. Threshold selection on the same labels does not provide a 95% guarantee for the selected policy. Freeze the policy, then assess it on a separate IID holdout:
calibroute validate --input holdout.csv --policy examples/policy.json --output holdout-report.json
Exit code 0 means the holdout upper bound meets the declared risk limit; 1 means it does not (including zero accepted samples); 2 means invalid input. Never tune against this holdout or reuse it to select among multiple policies. A pass does not cover distribution shift. See statistical scope.
Python API
from calibroute import PredictionRecord, fit_policy, route_batch
validation = [
PredictionRecord("a", 0.98, True),
PredictionRecord("b", 0.82, True),
PredictionRecord("c", 0.55, False),
]
policy = fit_policy(validation, max_risk=0.10, min_coverage=0.50,
risk_method="empirical") # Tiny illustrative sample only.
decisions, summary = route_batch(
[PredictionRecord("new", 0.74)],
policy,
)
Limitations
CalibRoute is an evaluation and routing tool, not a safety certification. Thresholds should be revalidated after changes to the model, task, prompt, or deployment distribution. See design principles for details.
Development
python -m unittest discover -s tests -v
See CONTRIBUTING.md and ROADMAP.md. Release preparation is documented in releasing. The Financial NER case study demonstrates the adapter and cross-domain failure pattern on 2,098 derived prediction rows.
License
MIT. See LICENSE.
Release files for calibroute-ai 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| calibroute_ai-0.3.0.tar.gz | 42.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| calibroute_ai-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.9 kB
Release files / calibroute_ai-0.3.0.tar.gz
| Download URL | calibroute_ai-0.3.0.tar.gz |
|---|---|
| Size | 42.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e9bfd07d0c103affd054bb983b533d8520cc255ab23f39954c46a1aadd154c9
|
|
BLAKE2b-256 checksum How to use checksums |
cf96178d66832468aeaf40a5e97e74ca0dad7dfb6164936b2e594f2e45ded394
|
| 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 Sep 21, 2026.
Transparency logRelease files / calibroute_ai-0.3.0-py3-none-any.whl
| Download URL | calibroute_ai-0.3.0-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce8a51934d082e1b3024ba232af59c99fa89764208972d4e9b8c837664201cf5
|
|
BLAKE2b-256 checksum How to use checksums |
e6afa17bb64cbfd35ac879932b6912a66710bce450b39d07f78d2abf42178fab
|
| 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 Sep 21, 2026.
Transparency log