About Method 01 - COMPAS 02 - AI Hiring 03 - German Credit 04 - Insurance Denial 05 - Benefits Denial 06 - Healthcare Readmission 07 - Tenant Screening Explainers Profiler Impact Roadmap FAQ

Algorithmic bias research · Open source

The bias is real.
So is the fix.

AI systems decide your freedom, your job, your future. This project proves the bias is measurable - and shows exactly how to remove it.

87%
Black defendants
flagged high-risk
0.4%
White defendants
flagged high-risk
97%
Bias reduction
achieved
COMPAS CRIMINAL JUSTICE AI HIRING DISCRIMINATION FAIRNESS GAP 86.77% → 15.69% 97.3% BIAS REDUCTION RANDOM FOREST CLASSIFIER DEMOGRAPHIC PARITY METRIC PROXY VARIABLE REMOVAL GERMAN CREDIT LENDING BIAS AGE DISCRIMINATION · 73.6% REDUCTION OPEN SOURCE · PUBLIC DATA INSURANCE DENIAL BIAS BMI + SMOKER + DIABETIC PROXIES AGE GAP 7.93% → 3.18% · 60% REDUCTION BENEFITS DENIAL BIAS RELATIONSHIP + MARITAL STATUS PROXIES SEX GAP 18.00% → 8.52% · 53% REDUCTION TENANT SCREENING BIAS RACE GAP 7.17% → 5.07% · 29% REDUCTION EQUALIZED ODDS · TPR + FPR PARITY DISPARATE IMPACT · 80% RULE FOUR-FIFTHS RULE · EEOC STANDARD FEEDBACK LOOP BIAS RETRAINING AMPLIFIES BIAS OVER TIME LABEL BIAS HISTORICAL DECISIONS CORRUPT TRAINING LABELS INDIVIDUAL FAIRNESS SIMILAR PEOPLE MUST BE TREATED SIMILARLY NEURAL NETWORKS WEIGHTS ENCODE BIAS FROM TRAINING DATA AI HALLUCINATION HIGH CONFIDENCE · ZERO EVIDENCE · SPARSE REGIONS REINFORCEMENT LEARNING REWARD FUNCTION IS POLITICAL · NOT TECHNICAL PROXY ENTANGLEMENT REDUNDANT CHANNELS · REMOVE THE CLUSTER · NOT ONE PROXY COMPAS CRIMINAL JUSTICE AI HIRING DISCRIMINATION FAIRNESS GAP 86.77% → 15.69% 97.3% BIAS REDUCTION RANDOM FOREST CLASSIFIER DEMOGRAPHIC PARITY METRIC PROXY VARIABLE REMOVAL GERMAN CREDIT LENDING BIAS AGE DISCRIMINATION · 73.6% REDUCTION OPEN SOURCE · PUBLIC DATA INSURANCE DENIAL BIAS BMI + SMOKER + DIABETIC PROXIES AGE GAP 7.93% → 3.18% · 60% REDUCTION BENEFITS DENIAL BIAS RELATIONSHIP + MARITAL STATUS PROXIES SEX GAP 18.00% → 8.52% · 53% REDUCTION TENANT SCREENING BIAS RACE GAP 7.17% → 5.07% · 29% REDUCTION EQUALIZED ODDS · TPR + FPR PARITY DISPARATE IMPACT · 80% RULE FOUR-FIFTHS RULE · EEOC STANDARD FEEDBACK LOOP BIAS RETRAINING AMPLIFIES BIAS OVER TIME LABEL BIAS HISTORICAL DECISIONS CORRUPT TRAINING LABELS INDIVIDUAL FAIRNESS SIMILAR PEOPLE MUST BE TREATED SIMILARLY NEURAL NETWORKS WEIGHTS ENCODE BIAS FROM TRAINING DATA AI HALLUCINATION HIGH CONFIDENCE · ZERO EVIDENCE · SPARSE REGIONS REINFORCEMENT LEARNING REWARD FUNCTION IS POLITICAL · NOT TECHNICAL PROXY ENTANGLEMENT REDUNDANT CHANNELS · REMOVE THE CLUSTER · NOT ONE PROXY
01About the Project

Code that holds algorithms accountable

"AI systems are making decisions about your freedom, your job, and your healthcare. This project proves the bias is real. And it shows exactly how to fix it."
Python scikit-learn pandas Facial Recognition (Coming) Mortgage Lending (Coming)

Fair Code is a research and engineering project that exposes bias in real-world AI systems and demonstrates concrete mitigation strategies. Both projects follow the same structure.

Train a biased model. Measure the fairness gap. Engineer a fair model. Measure again. No theory. Just data, code, and results.

The bias in these systems is documented, measurable, and fixable. Removing a protected attribute isn't enough. Proxy variables carry the same signal through. Both must go.

yakew7/Fair-Code
02Methodology

The pipeline

Every project in this repo follows the same bias detection and mitigation workflow. Reproducible. Transparent. Measurable.

config.py
# ── model config ──────────────────
model = RandomForestClassifier
split = 80/20 # random_state=42
metric = demographic_parity
method = pre_processing_drop
stats = bootstrap_ci + permutation
01

Load Dataset

Real-world data with demographic signals: ProPublica COMPAS, Kaggle recruitment datasets.

02

Train Biased Model

Include protected attributes (race, gender, age) alongside predictive features.

03

Measure Fairness Gap

Calculate positive prediction rate differences across demographic groups. Each gap ships with a 95% bootstrap confidence interval and a permutation-test p-value, so a real disparity can be told apart from sampling noise.

04

Remove Attributes + Proxies

Drop protected attributes and correlated proxy variables that smuggle bias back in.

05

Retrain & Re-measure

Fair model trained on merit features only. Gap measured again. Results compared.

03Projects

The experiments

↗ View All Code
Filter: - of -
No results
No experiments match that query. Try a different term or clear the filter.
01
PROJECT - 01
COMPAS

A real algorithm used in US courtrooms. ProPublica's public dataset, 70,000+ records. The bias is not a glitch. It's baked in.

FAIRNESS GAP BEFORE
86.77%
AFTER MITIGATION
15.69%
71% reduction
unfair.py - BIASED MODEL
--- BIASED MODEL RESULTS ---
Black Defendant High-Risk Rate: 87.16%
White Defendant High-Risk Rate: 0.40%
Fairness Gap: 86.77%
95% CI: [85.14%, 88.31%] · n=10,000 resamples
Permutation p-value: 0.0000 · significant
fair.py - MITIGATED MODEL
--- MITIGATED (UNBIASED) RESULTS ---
Black Defendant High-Risk Rate: 84.71%
White Defendant High-Risk Rate: 69.02%
New Fairness Gap: 15.69%
95% CI: [12.82%, 18.58%] · n=10,000 resamples
Permutation p-value: 0.0000 · significant
Key Insight

Removing race alone isn't enough. Custody Status is a proxy variable. It carries the racial signal through the model even when the race column is dropped. Both features had to go.

Black · BIASED
87.16%
White · BIASED
0.40%
Black · FAIR
84.71%
White · FAIR
69.02%
02
PROJECT - 02
AI HIRING

Women hired 20.9% less than equally qualified men. The algorithm wasn't told to discriminate. It learned to.

FAIRNESS GAP BEFORE
4.51%
AFTER MITIGATION
0.12%
97.3% reduction
unfair.py - BIASED MODEL
--- BIASED MODEL OUTPUT ---
Male Candidate Hire Rate: 21.62%
Female Candidate Hire Rate: 17.10%
Original Fairness Gap: 4.51%
95% CI: [3.52%, 5.53%] · n=10,000 resamples
Permutation p-value: 0.0000 · significant
fair.py - MITIGATED MODEL
--- MITIGATED MODEL OUTPUT ---
Male Candidate Hire Rate: 11.48%
Female Candidate Hire Rate: 11.35%
New Fairness Gap: 0.12%
95% CI: [−0.69%, 0.93%] · n=10,000 resamples
Permutation p-value: 0.7757 · not significant
Key Insight

Dropping gender and age, retaining only Experience Years and Technical Test Score, collapsed the fairness gap from 4.51% to 0.12%. Merit features alone produce near-perfect demographic parity.

Male · BIASED
21.62%
Female · BIASED
17.10%
Male · FAIR
11.48%
Female · FAIR
11.35%
03
PROJECT - 03
GERMAN CREDIT

A lending model rates young applicants as bad credit risks at 6+ points higher than older applicants with identical financial profiles. It learned age from job tenure.

FAIRNESS GAP BEFORE
7.16%
AFTER MITIGATION
1.89%
73.6% reduction
unfair.py - BIASED MODEL
--- BIASED MODEL RESULTS ---
Older Applicants (30+) Good Credit: 83.97%
Young Applicants (<30) Good Credit: 76.81%
Fairness Gap: 7.16%
95% CI: [−4.14%, 18.98%] · n=10,000 resamples
Permutation p-value: 0.2564 · not significant
fair.py - MITIGATED MODEL
--- MITIGATED (UNBIASED) RESULTS ---
Older Applicants (30+) Good Credit: 80.15%
Young Applicants (<30) Good Credit: 78.26%
New Fairness Gap: 1.89%
95% CI: [−9.86%, 13.80%] · n=10,000 resamples
Permutation p-value: 0.8548 · not significant
Key Insight

Employment tenure looks like a legitimate financial signal - and it is. But it's also a near-perfect proxy for age. A 24-year-old cannot have 10 years of employment history. The model penalizing short tenure was partially penalizing youth. Dropping both age and employment forced it to evaluate what a borrower has - savings, credit history, loan purpose - rather than how long they've been alive. A caveat the new significance testing makes explicit: on a 200-row test set this 7.16% gap is not statistically significant (p = 0.26, CI spans zero) - a reminder that small samples demand a confidence interval before a point estimate is read as proof.

Older · BIASED
83.97%
Young · BIASED
76.81%
Older · FAIR
80.15%
Young · FAIR
78.26%
04
PROJECT - 04
INSURANCE DENIAL

An insurance AI flags older patients for high-cost claims at 7.93 points higher than younger patients. BMI, smoking status, and diabetes status encode race without naming it.

AGE FAIRNESS GAP BEFORE
7.93%
AFTER MITIGATION
3.18%
60% reduction · Gender gap: 72% reduction
unfair.py - BIASED MODEL
--- BIASED MODEL RESULTS ---
Older (35+) High-Cost Flag Rate: 44.59%
Young (<35) High-Cost Flag Rate: 36.67%
Age Fairness Gap: 7.93%
CI [−3.99%, 19.84%] · p=0.2207 · not significant
Gender Fairness Gap: −5.44%
CI [−17.35%, 6.47%] · p=0.3834 · not significant
fair.py - MITIGATED MODEL
--- MITIGATED (UNBIASED) RESULTS ---
Older (35+) High-Cost Flag Rate: 50.68%
Young (<35) High-Cost Flag Rate: 47.50%
New Age Fairness Gap: 3.18%
CI [−8.90%, 15.25%] · p=0.6288 · not significant
New Gender Fairness Gap: 1.54%
CI [−10.37%, 13.53%] · p=0.8111 · not significant
Key Insight

BMI, smoking status, and diabetes diagnosis rates all differ significantly by race and class - so a model trained on them learns to discriminate by race without the word ever appearing. These are the CustodyStatus of health insurance: clinical-sounding features that carry protected-class signal because of structural inequalities baked into American healthcare. Dropping them alongside age and gender reduced the age gap by 60% and the gender gap by 72%. Honest caveat, now that every gap carries a p-value: on this small test set neither the age nor the gender gap is statistically significant (both p > 0.2, CIs span zero), so these numbers show the mechanism and direction of the bias rather than a proven effect size - exactly the distinction the confidence intervals exist to enforce.

Older · BIASED
44.59%
Young · BIASED
36.67%
Older · FAIR
50.68%
Young · FAIR
47.50%
05
PROJECT - 05
BENEFITS DENIAL

An automated means-test flags male applicants as ineligible at 18 points higher than female applicants - not because of what they earn, but because of who they're married to.

SEX FAIRNESS GAP BEFORE
18.00%
AFTER MITIGATION
8.52%
53% reduction · Race gap: 46% · Origin gap: 88%
unfair.py - BIASED MODEL
Model Accuracy: 85.66%
Male applicants : 25.71% flagged ineligible
Female applicants : 7.71% flagged ineligible
Fairness Gap (Sex): 18.00%
CI [16.29%, 19.73%] · p=0.0000 · significant
US-born : 20.20% flagged ineligible
Foreign-born : 15.81% flagged ineligible
Fairness Gap (Origin): 4.40%
CI [1.34%, 7.31%] · p=0.0076 · significant
Under 55 : 19.36% flagged ineligible
55+ (elderly) : 22.08% flagged ineligible
Fairness Gap (Age): −2.72%
CI [−5.53%, 0.13%] · p=0.0522 · not significant
White/Asian-PI : 21.22% flagged ineligible
Other minorities : 8.47% flagged ineligible
Fairness Gap (Race): 12.75%
CI [10.43%, 14.99%] · p=0.0000 · significant
fair.py - MITIGATED MODEL
Model Accuracy: 83.05%
Male applicants : 14.84% flagged ineligible
Female applicants : 6.32% flagged ineligible
New Fairness Gap (Sex): 8.52%
CI [7.07%, 10.01%] · p=0.0000 · significant
US-born : 12.08% flagged ineligible
Foreign-born : 11.55% flagged ineligible
New Fairness Gap (Origin): 0.52%
CI [−2.17%, 3.04%] · p=0.7051 · not significant
Under 55 : 11.61% flagged ineligible
55+ (elderly) : 14.41% flagged ineligible
New Fairness Gap (Age): −2.79%
CI [−5.17%, −0.43%] · p=0.0158 · significant
White/Asian-PI : 12.81% flagged ineligible
Other minorities : 5.91% flagged ineligible
New Fairness Gap (Race): 6.90%
CI [4.94%, 8.74%] · p=0.0000 · significant
Key Insight

Automated benefits systems don't need to name sex or race to discriminate by them. relationship (Husband/Wife), marital.status, hours.per.week, and occupation are the CustodyStatus of welfare AI - features that sound purely economic but carry protected-class signal because of how work, caregiving, and labour markets are structurally organised. Dropping all four alongside the direct protected attributes reduced the sex gap by 53%, the race gap by 46%, and the national-origin gap by 88%.

Male · BIASED
25.71%
Female · BIASED
7.71%
Male · FAIR
14.84%
Female · FAIR
6.32%
06
PROJECT - 06
HEALTHCARE READMISSION

A hospital readmission model flags patients for high clinical risk using payer code and discharge destination - variables that measure insurance access, not medical severity.

AGE FAIRNESS GAP BEFORE
0.28%
AFTER MITIGATION
0.09%
Age: 68% reduction · Race: 25% reduction
unfair.py - BIASED MODEL
Model Accuracy: 88.79%
Male patients : 0.22% flagged high-risk
Female patients : 0.24% flagged high-risk
Fairness Gap (Gender): −0.02%
CI [−0.16%, 0.11%] · p=0.7707 · not significant
Caucasian/Asian : 0.25% flagged high-risk
Other minorities : 0.17% flagged high-risk
Fairness Gap (Race): 0.08%
CI [−0.07%, 0.21%] · p=0.3798 · not significant
Under 70 : 0.36% flagged high-risk
70+ (elderly) : 0.08% flagged high-risk
Fairness Gap (Age): 0.28%
CI [0.15%, 0.41%] · p=0.0000 · significant
fair.py - MITIGATED MODEL
Model Accuracy: 88.74%
Male patients : 0.11% flagged high-risk
Female patients : 0.06% flagged high-risk
New Fairness Gap (Gender): 0.04% ↑
CI [−0.04%, 0.13%] · p=0.3336 · not significant
Caucasian/Asian : 0.10% flagged high-risk
Other minorities : 0.04% flagged high-risk
New Fairness Gap (Race): 0.06%
CI [−0.03%, 0.13%] · p=0.3918 · not significant
Under 70 : 0.13% flagged high-risk
70+ (elderly) : 0.03% flagged high-risk
New Fairness Gap (Age): 0.09%
CI [0.02%, 0.17%] · p=0.0270 · significant
Key Insight

Healthcare readmission models don't need race or gender to discriminate by them. payer_code, discharge_disposition_id, medical_specialty, and number_inpatient are the CustodyStatus of clinical AI - features that look like neutral operational data but encode structural inequalities in insurance, geography, and access to preventive care. The age gap reduced 68% and the race gap 25%. With significance testing added, the picture sharpens: on this large dataset only the age gap clears significance (p < 0.05, CI above zero) in both models, while the gender and race gaps sit within sampling noise (p > 0.3, CIs crossing zero) - so the age reduction is the one effect the numbers actually support. The gender gap moved from −0.02% to 0.04% - a shift well inside the noise band, not a real widening. The causal direction matters: lower SNF access creates readmission risk. The patient does not bring the risk to the gap - the gap creates the risk.

Under 70 · BIASED
0.36%
70+ · BIASED
0.08%
Under 70 · FAIR
0.13%
70+ · FAIR
0.03%
07
PROJECT - 07
TENANT SCREENING

A tenant-screening company buys a criminal-history risk score and hands the landlord a high-risk flag on the applicant - a flag that fires 7 points more often for Black applicants than white ones, before the landlord reads a word of the application.

RACE FAIRNESS GAP BEFORE
7.17%
AFTER MITIGATION
5.07%
Race: 29% reduction
unfair.py - BIASED MODEL
Model Accuracy: 70.49%
Black applicants : 67.05% flagged high-risk
White applicants : 59.88% flagged high-risk
Fairness Gap (Race): 7.17%
CI [4.50%, 9.81%] · p=0.0000 · significant
fair.py - MITIGATED MODEL
Model Accuracy: 63.50%
Black applicants : 62.16% flagged high-risk
White applicants : 57.08% flagged high-risk
New Fairness Gap (Race): 5.07%
CI [2.30%, 7.83%] · p=0.0007 · significant
Key Insight

Removing Race from a tenant-screening model does almost nothing, because the score is built out of criminal-history counts - and those counts are not a race-neutral measure of risk. Prior arrest and conviction episodes measure how often the system has stopped, charged, and convicted a person, and over-policing means Black applicants carry more of them for the same behaviour. Every one of the twelve proxies differs by race at p far below 0.05, with prior violent-arrest and gun-charge history the strongest, and Residence_Changes standing in for the eviction history real screeners buy. Dropping race and all twelve proxies only cuts the gap from 7.17% to 5.07% (a 29% reduction), and it stays significant (p=0.0007) - because the residual bias lives in the label itself. The model is trained to predict re-arrest, and re-arrest is a policed quantity. When the target is downstream of the same enforcement that produced the proxies, no feature removal fully closes the gap - the real remedy is questioning whether a re-arrest-derived score belongs in a housing decision at all.

Black · BIASED
67.05%
White · BIASED
59.88%
Black · FAIR
62.16%
White · FAIR
57.08%
Research Tools · Try it live

Open Dataset Profiler →

The audits above measure bias in a model. The Profiler works upstream: drop in any CSV and get an instant demographic representation audit - missing subgroups, skewed age/sex distributions, geographic under-sampling.

🔒Runs entirely in your browser - your file never leaves your machine.

Research Tools · Reproducible pipeline

Cross-Domain Benchmark Harness →

The seven audits above each run a bespoke unfair.py / fair.py pair. The benchmark harness applies one uniform pipeline to all seven instead: five mitigation strategies - baseline, drop-the-protected-attribute, drop-protected-plus-proxies, Fairlearn ExponentiatedGradient in-processing, and Fairlearn ThresholdOptimizer post-processing - each run across three model families and scored on six fairness metrics with a bootstrap confidence interval and a permutation-test p-value. On COMPAS the demographic parity gap goes 86% → 18% → 12% → 1.4% → 2.4% across the five strategies - the two strongest, constraint-based tools land within a point of the simple proxy-removal fix, which is the basis for calling that residual gap a floor rather than a limitation of any one method.

📊Contributor-facing: add an audit.yaml manifest, the harness runs the rest. Results and figures committed to results/.

04Explainers

The concepts

↗ Source markdown

Each card opens a focused explainer page. The homepage stays light, the long-form write-ups stay on site, and the source markdown lives in the repo.

Filter: - of -
No results
No explainers match that query. Try a different term or clear the filter.
05Why This Matters

These are not hypotheticals

87%

of companies use AI to screen job applicants before a human sees a resume (Forbes, 2024)

46

US states have used algorithmic risk tools in criminal sentencing

0

federal laws currently require hiring AIs to be audited for gender or racial bias

Algorithms like COMPAS are deployed in courtrooms right now. Hiring AIs filter your resume before a human ever reads it. The bias in these systems is documented, measurable, and fixable.

06What's Next

The roadmap

More datasets, more domains, more bias exposed and fixed. Follow the project on Instagram for updates.

COMPAS Criminal Justice
ProPublica · 70k+ records · 71% bias reduction
AI Recruitment Bias
Kaggle dataset · gender + age · 97.3% bias reduction
German Credit Lending Bias
UCI Statlog · age + tenure proxy · 73.6% bias reduction
Insurance Denial - Healthcare Bias
Kaggle · age + gender + BMI/smoker/diabetic proxies · 60% + 72% reduction
Benefits Denial - Welfare Eligibility Bias
UCI Adult Census · sex + race + origin + age + 4 proxies · 53% / 46% / 88% reduction
Healthcare Readmission - Clinical Bias
Diabetes 130-US Hospitals · race + gender + age + 4 proxies · 68% / 25% reduction
Tenant Screening - Rental Application Bias
NIJ Recidivism Challenge · race + 12 criminal-history / housing proxies · 29% reduction
Explainer: Proxy Variables
Concept deep-dive · detection code · real-world proof
Explainer: Sampling Bias
Gender Shades study · audit code · mitigation strategies
Explainer: SHAP Values
Model explainability · bias auditing · Shapley attribution
Explainer: Equalized Odds
TPR + FPR parity · COMPAS proof · calibration conflict · fairlearn detection code
Explainer: Disparate Impact (80% Rule)
Four-Fifths Rule · EEOC standard · hiring audit proof · Griggs v. Duke Power
Explainer: Why Fairness Metrics Conflict
Chouldechova impossibility · COMPAS dual-reading · full audit code · base rate analysis
Explainer: Calibration
Differential calibration · COMPAS score bands · MACE detection code · Chouldechova trade-off
Explainer: Demographic Parity
EEOC 80% rule · hiring bias proof · multi-group audit code · impossibility trade-offs
Explainer: Feedback Loop Bias
Predictive policing case · retraining amplification · drift detection code · mitigation strategies
Explainer: Disparate Treatment
Title VII · feature set audit · two-stage treatment → impact check · proxy detection · McDonnell Douglas
Explainer: Label Bias
Biased ground truth · conditional label audit · noise-robust training · propensity matching · Jacobs & Wallach
Explainer: Individual Fairness
Lipschitz condition · matched-pair audit · consistency score · similarity metric · Dwork et al. 2012
Explainer: Counterfactual Fairness
Structural causal model · causal DAG · proxy vs resolving variables · COMPAS policing chain · Kusner et al. 2017
Explainer: What Happens Inside a Neural Network
Forward pass · weights · loss function · backpropagation · SHAP inspection · hiring bias proof
Explainer: Why AI Hallucinates
OOD confidence · sparse feature regions · Mata v. Avianca · insurance denial proof · RAG limitations
Explainer: Reinforcement Learning
Reward function design · COMPAS as RL-adjacent system · proxy exploitation · credit assignment failure
Explainer: Proxy Entanglement
Correlated proxy clusters · Healthcare Readmission proof · cluster removal · causal root analysis
Explainer: ML Bias
Training data bias · label bias · proxy variables · feedback loops · disparate impact vs treatment · COMPAS proof · detection code
Explainer: Data Leakage
Target leakage · train-test contamination · COMPAS CustodyStatus proof · temporal splitting · SMOTE order · detect_target_leakage() · check_preprocessing_leakage()
Explainer: How AI Detects Patterns
Random Forest splits · feature importance ranking · COMPAS proof · correlation vs causation · proxy detection code
Explainer: Distribution Shift
Covariate shift · label shift · concept drift · Healthcare Readmission proof · KS test · chi-squared drift detection · fairness gap re-opening
Explainer: The Biggest Myth About AI Objectivity
Objectivity myth · COMPAS as "neutral" risk score · proxy removal proof · audit-as-snapshot limits · fairness metric choice
Explainer: What Is a Confounding Variable?
Spurious correlation · causal graph · COMPAS CustodyStatus proof · stratified audit · proxy vs confounder · Simpson's Paradox · propensity adjustment
Explainer: What Is Predictive Parity?
Sufficiency vs separation · PPV equality · COMPAS ProPublica vs Northpointe dispute · Chouldechova impossibility proof · base-rate trade-off
Explainer: False Positives vs. False Negatives in Medical Risk Models
False positive vs false negative cost · Obermeyer 2019 healthcare proof · cost-weighted thresholds · Healthcare Readmission audit · equalized odds link · threshold tuning
What Is Supervised Learning?
Input-label mapping · AI Fair Recruitment proof · train/test split · label as proxy · German Credit Lending · generalisation · distribution shift
Explainer: What Is Unsupervised Learning?
K-means clustering · Benefits Denial proof · no label, no ground truth · sex split recovered (89.3% male) · race split · ZIP-code pricing precedent · proxy without supervision
Explainer: What Is Model Drift?
Data drift vs concept drift · German Credit Lending proof · rolling-window monitoring · gap 4.3%-15.1% across windows · PSI · Page-Hinkley change-point test · audit-as-snapshot limits
Explainer: What Is Selection Bias?
Berkson's paradox · reject inference in credit scoring · German Credit Lending's 700/300 split with zero rejected applicants · sampling-bias vs selection-bias scoping · collider-bias simulation
Explainer: What Is Automation Bias?
Cognitive deference to AI · COMPAS courtroom case study · omission + commission errors · perceived objectivity · cognitive offloading · disparity amplification in human-in-the-loop decisions · detection code · mitigation strategies
Explainer: What Is a ROC Curve and AUC?
ROC curve + AUC as ranking quality · why a threshold-free score hides where you operate and per-group differences · COMPAS 0.68 baseline AUC · per-group AUC + overlaid ROC detection code
Explainer: What Is a Protected Attribute?
What a protected attribute is · how the law recognizes it · why fairness-through-unawareness fails by hiding the bias behind proxies
Explainer: What Is a Confusion Matrix?
TP/FP/FN/TN · precision, recall, FPR, FNR · the building block behind most fairness metrics
Explainer: What Is Class Imbalance?
Why skewed positive/negative ratios wreck naive accuracy · minority subgroups hit hardest · oversampling, undersampling, SMOTE, and class weights - and when they help or hurt fairness
Explainer: What Is the Bias-Variance Trade-off?
Underfit vs overfit · why an overfit model memorizes the majority and fails the minority · statistical bias vs societal/algorithmic bias
Explainer: Why Accuracy Is Not Enough in Healthcare AI
The accuracy paradox on rare clinical outcomes · per-group recall + false-negative gaps hidden by one score · Healthcare Readmission audit · Obermeyer et al. 2019 · accuracy-vs-recall detection code
Explainer: Miscalibration in Clinical Risk Scores
Same risk score, different real-world risk depending on the patient's group · reliability diagrams and calibration slope/intercept per group · Healthcare Readmission audit · Obermeyer et al. 2019
Explainer: Missing Data as Bias in EHRs
How unequal access to care turns into unequal missingness models misread · MCAR/MAR/MNAR · Healthcare Readmission audit's 10.7-point payer-code gap by race
Explainer: Why Medical Imaging Models Fail on Underrepresented Groups
Representation gaps vs. shortcut learning on device/site artifacts · Zech et al. 2018 hospital-site shortcut · Larrazabal et al. 2020 sex-imbalance study
Fairness Dashboard
Interactive web app for live bias analysis
Facial Recognition Gaps
MIT Gender Shades methodology · coming soon
HMDA Mortgage Lending
Federal lending data · racial bias in loan approvals
Explainer: Race Correction in Clinical Algorithms
eGFR, spirometry, VBAC · why "race-adjusted" formulas bake bias into the math · healthcare focus · freeze-safe
Explainer: The Obermeyer Case - Cost as a Proxy for Health Need
The 2019 algorithm that under-referred sicker Black patients · healthcare focus · freeze-safe
Explainer: Underdiagnosis Bias
When the label itself is sicker for one group · historical care gaps in the training target · healthcare focus · freeze-safe
07FAQ

Questions, answered

The short version of what this project is, what it isn't, and how to reach a human about it.

What is Fair Code, exactly?

An open-source research project that audits real-world AI systems for demographic bias, then engineers a fixed version of the same model and measures the gap before and after. Every audit follows the same pipeline: train a biased model, measure the fairness gap, remove protected attributes and proxy variables, retrain, and measure again.

Is this legal, medical, or compliance advice?

No. Fair Code is a research and engineering project, not legal or regulatory advice. The audits demonstrate that bias is measurable and fixable in a research setting - they are not a substitute for a formal compliance review, and no results here should be relied on as legal counsel for a production system.

Which fairness metric does it use, and why?

Demographic Parity is the primary constraint used to mitigate bias, alongside six fairness metrics used to measure it. See the Methodology section and the Fairness Metric Conflicts explainer for why no single metric captures fairness completely, and why the choice of metric is itself a judgment call.

Does the Dataset Profiler upload my file anywhere?

No. The Open Dataset Profiler runs entirely client-side in your browser - your CSV is parsed and analyzed locally and is never uploaded to a server.

Can I contribute a new audit or dataset?

Yes - contributions are welcome. See CONTRIBUTING.md on GitHub. Note that the benchmark results are currently frozen for a paper in peer review, so new audits are staged on a branch and merged into main after publication rather than being blocked outright.

What's the license?

MIT. See the LICENSE file - the code, audits, and explainers are free to use, modify, and redistribute with attribution.

How do I get in touch?

Email yashkewlani2020@gmail.com for questions, bug reports, or collaboration - or open an issue on GitHub.