02 / 31 · AI/ML · Open Source · featured

relfair

Relationship-aware counterfactual fairness testing · PyPI

interactive demo
loading demo…
about

A Python library that propagates protected-attribute interventions through a causal DAG so counterfactual fairness tests stay on the data manifold. Naive flip tests miss proxy bias — a model that learned relationship=Husband ⇒ Male reads a flipped row as off-distribution. relfair propagates the intervention: Husband → Wife, occupation update, household role update. On Adult, ACS Income, and German Credit, it detects 3–4× more discrimination than naive flipping. Ships with an NYC Local Law 144 audit engine — selection rates, four-fifths rule, bootstrap CIs, and DCWP-compliant PDF reports.

what it does
  • 01Causal-graph-aware counterfactual engine with conditional transition rules (Husband → Wife only when sex flips)
  • 02100% recall on hard-rule constraint violations vs IsolationForest 7.5% (which cannot localize attribute-pair contradictions)
  • 03NYC Local Law 144 audit CLI — selection rates, impact ratios, four-fifths flags, intersectional sex × race cross-tabs
  • 04Bootstrap confidence intervals, Fisher exact, and two-proportion z-tests for statistical rigor
  • 05DCWP-compliant PDF + JSON reports via WeasyPrint and Jinja2 templates
  • 06Benchmarked on Adult (Husband rows), ACS Income CA, and German Credit — all reproducible from experiments/