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 sentence- and entity-level output adapters
- ShiftGuard agent-replay adapter and offline confidence audit
- 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.
Version compatibility
Release 0.4.0 adds entity-level NER, ShiftGuard, and comparison reports to
the PyPI package. Upgrade with python -m pip install --upgrade calibroute-ai.
| Capability | PyPI 0.3.0 | PyPI 0.4.0 |
|---|---|---|
audit, fit, validate, route |
Available | Available |
Three-rule comparison report: compare |
Not included | Available |
| Tie-aware thresholds, holdout assessment, and confidence-shift routing | Available | Available |
Financial NER sentence adapter: convert-financial-ner |
Available | Available |
Financial NER entity adapter: convert-financial-ner-entities |
Not included | Available |
ShiftGuard replay adapter: convert-shiftguard |
Not included | Available |
| Document-review walkthrough | Compatible; obtain script from GitHub | Compatible; obtain script from GitHub |
| Financial NER sentence case study | Compatible; obtain script/data from GitHub | Compatible; obtain script/data from GitHub |
| ShiftGuard case study | Not compatible | Compatible; obtain script/data from GitHub |
For reproducible installation, use python -m pip install calibroute-ai==0.4.0.
Example scripts and data are available in the repository; installing the wheel
does not install the example folders. Check out tag v0.4.0 for examples matching
this release; GitHub main may receive further development changes.
To check the active environment, run python -m calibroute.cli --help and
python -m pip show calibroute-ai. Check the listed commands and installation location; record
git rev-parse HEAD when reporting results from a source checkout.
Quick start
To compare all-accept, a fixed threshold, and CalibRoute on the same labeled batch, see the one-command comparison guide (0.4.0 or newer).
New here? Follow the document-review walkthrough: one offline script demonstrates development data, a separate holdout, and routing using the published 0.3.0 API. It also explains how to use your own predictions.
# 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.
Tried it on a task? Share a usage report,
including unsuccessful trials or integration difficulties.
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.
The ShiftGuard agent example audits 384 frozen
proposals, keeps task templates separate, and reports when no confidence
threshold meets the declared empirical risk target. Use CalibRoute 0.4.0 or newer
for the convert-shiftguard command.
License
MIT. See LICENSE.
Release files for calibroute-ai 0.4.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.4.0.tar.gz | 89.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| calibroute_ai-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 114.6 kB
Release files / calibroute_ai-0.4.0.tar.gz
| Download URL | calibroute_ai-0.4.0.tar.gz |
|---|---|
| Size | 89.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6166c7d3b9e0c1fa3e0d05c321c770d874fde95608cb7241d5f45beedc3bca09
|
|
BLAKE2b-256 checksum How to use checksums |
1eb0f7e62c1ef121003a894e0f221bdf512641c5965c9e30bd3bfce75150ff85
|
| 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 26, 2026.
Transparency logRelease files / calibroute_ai-0.4.0-py3-none-any.whl
| Download URL | calibroute_ai-0.4.0-py3-none-any.whl |
|---|---|
| Size | 25.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b86cc43d87ae4438c2fc57013fe1942aebdf93fe3b1c91c5dd0c598f41a323a
|
|
BLAKE2b-256 checksum How to use checksums |
64bdfae379828cd098eb51ed9146e6764aebfa2b777ee1ff73b9ef2f29e176d5
|
| 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 26, 2026.
Transparency log