Skip to main content

FPRCal

License

Stable low-FPR calibration for detection model scores across model releases, with a fixed log-scale interpretability contract (0.5 = 0.1% FPR, 0.7 = 0.01%, 0.85 = 0.001%).

Why

Raw scores from ML detectors drift across model releases and are not comparable across detector categories. Downstream product rules break on every retrain. This package calibrates detector scores to FPR on benign traffic, then applies a fixed log-scale transform so every calibrated value has the same FPR meaning across model versions and detector categories.

Install

python -m pip install fprcal

Requires Python 3.12+, numpy, scikit-learn, joblib.

For an editable development install, use python -m pip install -e ".[dev]".

Usage

from fprcal import fit_calibration_pipeline
import joblib

pipeline = fit_calibration_pipeline(benign_scores, n_knots=10000)
joblib.dump(pipeline, "calibration.pkl")

# In production:
pipeline = joblib.load("calibration.pkl")
calibrated = pipeline.predict(raw_scores.reshape(-1, 1))

The first-pass FPR-to-threshold spline uses Filliben median-centered plotting positions by default. Pass plotting_position="mean" to use the mean-centered k/(n+1) positions instead.

Demo

Reproduce the evaluation figure on the Credit Card Fraud Detection dataset (OpenML, 284K rows, 0.172% positives):

# One-time: download the data, train both detectors, save holdout scores
python examples/generate_credit_card_roc.py

# Fit on the calibration subset and evaluate its held-out complement
python examples/calibration_demo.py

Writes examples/credit_card_validation.png. See examples/credit_card_readme.md for dataset provenance.

License

Apache License 2.0. See LICENSE.

Maintainers can find the release procedure in RELEASING.md.

Metadata

Release files for fprcal 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 fprcal 0.1.0
File Size Uploaded
fprcal-0.1.0.tar.gz 1.4 MB Details

Built distribution (wheel)

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

Total release size: 1.4 MB

Release files / fprcal-0.1.0.tar.gz

Download URL fprcal-0.1.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
5903e9b6e0df446ab277fa61fc48f73f57dafccb4662a9b2826868d471043ce0
BLAKE2b-256 checksum
How to use checksums
2081a230fb456d7d7c32144b35da15beabf506c8456fe2c566992eaa80a8f39b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Jul 8, 2026.

Transparency log

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

Download URL fprcal-0.1.0-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
832bf9ba617e41dd3d12cd3ceda9473512424a77564cd7578e36524c30c0d7b7
BLAKE2b-256 checksum
How to use checksums
8da9cf92e1a24821abeee825a06de35f1e29798253183e14d05cb258b1ea3554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Jul 8, 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