← Back to work
Python Library · v0.3.0 · CI green

fairscope

Subgroup-stratified, calibration-aware fairness auditing as a pip-installable library — the uncertainty-aware statistical machinery that mainstream toolkits do not expose as first-class functions.

Rajveer Singh Pall · 2026 · MIT license

ProblemMainstream fairness toolkits don't expose subgroup-stratified statistical machinery — DeLong intervals, per-subgroup calibration, corrected gap tests — as first-class functions.
ApproachPackage peer-reviewed methods behind one-call domain audits (healthcare, lending, federated), each citing its source — plus one novel protocol on top, the five-axis CPFE.
SystemFive modules on NumPy / SciPy / scikit-learn, with reports that ship forest plots, reliability diagrams, and pre/post-recalibration ECE.
OutcomeShipped at v0.3.0 on PyPI — 100% line coverage on the statistical core, CI green across Python 3.9–3.12, live documentation site.
5Shipped modules
100%Core line coverage
3.9–3.12Python, CI green
MITOpen source · PyPI

The Discovery in One Figure

CapabilityAIF360Fairlearnfairscope
Per-subgroup AUC confidence interval (DeLong)
Per-subgroup Expected Calibration Error
Subgroup significance test + correction
Subgroup-stratified recalibrationpartial
Five-axis cross-platform protocol (CPFE)✓ novel
Per-node / federated audit

Verified against AIF360 0.6.1 and Fairlearn 0.14.0 (checked 2026-06). Those toolkits do bias mitigation; fairscope does uncertainty-aware measurement — they are complementary.

The Library in Two Minutes

A fairness number without an uncertainty band is a coin flip you can't see. fairscope treats fairness auditing as a statistical measurement problem: for every protected subgroup it reports not just an accuracy or AUC, but a DeLong confidence interval, a calibration error, and whether the gap between subgroups is statistically significant after multiple-comparison correction. It then hands you a subgroup-stratified recalibration interface to actually fix the calibration it just measured — with the error reported before and after. One from_scores(...) call produces a report with tables, forest plots, and reliability diagrams.

The Gap It Fills

AIF360 and Fairlearn are excellent at bias mitigation — they change the model. Neither exposes the uncertainty-aware measurement a reviewer actually asks for: a per-subgroup AUC with an analytic confidence interval, per-subgroup calibration error, or a corrected significance test on the gap between groups. fairscope fills exactly that gap, and adds one genuinely new protocol — the five-axis Cross-Platform Fairness Evaluation — on top. Everything except CPFE ports a documented method and cites its source; it invents no new mathematics.

How It Works

Point it at scores and a protected attribute; it returns an audit. Under the hood, each domain dispatches the same statistical core, then layers on domain-specific reporting.

01
Pass scores + subgroupy_true, y_score, and a protected attribute aligned row-for-row
02
Measure per subgroupDeLong AUC CI (fast midrank) · ECE / MCE · Brier · F1
03
Test the gapspaired / unpaired DeLong · stratified bootstrap · Bonferroni / BH correction
04
Recalibratetemperature scaling or isotonic, per subgroup, with pre/post-ECE
05
Reporttidy tables, forest plots, reliability diagrams, optional PDF / SHAP

What's Inside — Five Modules

coreDeLong CI, bootstrap-AUC test, ECE/MCE + reliability, multiple-testing correction, subgroup metrics — 100% line coverage.
healthcareOne-call clinical fairness audit and report: tables, forest & reliability plots, PDF, optional SHAP.
nlp — CPFEThe novel five-axis cross-platform protocol (the centerpiece) plus Captum attribution-stability analysis.
federatedPer-node DeLong, cross-node disparity, and per-node recalibration — audits predictions only, no training, no privacy claim.
lendingAnnual approval-gap analysis and subgroup CATE via Causal Forest Double ML (needs the econml extra).

What This Changes

It turns the research program's methods into something anyone can pip install: the exact per-subgroup, uncertainty-aware statistics used across the diabetes, mortgage, and mental-health-NLP papers, packaged once, tested to a reference value, and cited to source. Fairness measurement stops being bespoke notebook code and becomes a reusable, reviewable library.

Complementary to AIF360 / Fairlearn, not a replacement — measurement, not mitigation. The federated module provides no privacy guarantee; committed fixtures are small, synthetic, and labelled as such.

↗ View on GitHub ↗ Documentation ↗ PyPI

Grounded in Published Research

fairscope ports methods from the author's own papers — it invents no new mathematics, and each function cites its source: the diabetes external-validation study (IEEE CIPHER-2026), the five-axis CPFE mental-health NLP audit, the federated-learning diabetes work, and both mortgage-lending papers.

Citation

Rajveer Singh Pall. "fairscope: Subgroup-Stratified, Calibration-Aware Fairness Auditing." v0.3.0, 2026. MIT license. ORCID 0009-0001-6762-6134. Cite via CITATION.cff in the repository.

Related Research