Skip to content
AI360Xpert

AI Fairness

AI fairness asks whether a model treats different groups equitably — and reveals that multiple intuitive definitions of fairness are mathematically incompatible, forcing explicit value choices that cannot be avoided by technical means alone.

AI fairness asks whether a model treats different groups equitably — and reveals that multiple intuitive definitions of fairness are mathematically incompatible, forcing explicit value choices that cannot be avoided by technical means alone.
AI fairness asks whether a model treats different groups equitably — and reveals that multiple intuitive definitions of fairness are mathematically incompatible, forcing explicit value choices that cannot be avoided by technical means alone.

Why Does This Exist?

ML systems are now used for loan approvals, hiring, medical diagnoses, criminal justice risk scores, and content moderation. These are decisions that affect people's lives. When a model systematically favors or disadvantages groups based on protected attributes — race, gender, age, disability — it can perpetuate or amplify existing social inequities at machine speed and scale.

The COMPAS recidivism prediction tool (used in U.S. courts to predict re-offense likelihood) was found to have a false positive rate for Black defendants that was twice as high as for White defendants. Understanding what fairness means — and why it's hard — is the first step toward doing better.

Think of It Like This

A court that acquits at different rates by race

Imagine a court that acquits 80% of innocent White defendants but only 60% of innocent Black defendants, even though both groups commit the same proportion of crimes. No one would call this fair. ML models can do the equivalent — systematically failing for one group while succeeding for another — while reporting a high aggregate accuracy that hides the disparity.

How It Actually Works

Formal fairness definitions

There is no single definition of fairness. The major definitions make different value judgments:

Group fairness: Demographic parity (statistical parity) P(Y^=1A=0)=P(Y^=1A=1)P(\hat{Y} = 1 \mid A = 0) = P(\hat{Y} = 1 \mid A = 1) The positive prediction rate must be equal across groups. Does not require equal accuracy — only equal selection rates.

Equalized odds P(Y^=1Y=y,A=0)=P(Y^=1Y=y,A=1)y{0,1}P(\hat{Y} = 1 \mid Y = y, A = 0) = P(\hat{Y} = 1 \mid Y = y, A = 1) \quad \forall y \in \{0, 1\} Equal true positive rates AND equal false positive rates across groups. Requires the model to make errors at the same rate for everyone.

Equal opportunity (a relaxation) P(Y^=1Y=1,A=0)=P(Y^=1Y=1,A=1)P(\hat{Y} = 1 \mid Y = 1, A = 0) = P(\hat{Y} = 1 \mid Y = 1, A = 1) Only equal true positive rates — qualified individuals get equal chances.

Individual fairness Similar individuals should be treated similarly: dY(f^(x1),f^(x2))LdX(x1,x2)d_Y(\hat{f}(x_1), \hat{f}(x_2)) \leq L \cdot d_X(x_1, x_2). Requires defining a meaningful similarity metric on individuals, which is often as contested as fairness itself.

Calibration P(Y=1p^=p,A=a)=pP(Y = 1 \mid \hat{p} = p, A = a) = p for all groups aa. The predicted probability is an accurate estimate of the true probability for each group.

The impossibility theorem (Chouldechova, 2017)

When base rates differ between groups (i.e., P(Y=1A=0)P(Y=1A=1)P(Y=1|A=0) \neq P(Y=1|A=1)), it is mathematically impossible to simultaneously satisfy:

  1. Equal false positive rates across groups
  2. Equal false negative rates across groups
  3. Overall calibration

You must choose which notion to prioritize. This is a values choice, not a technical one.

Code

import numpy as npimport pandas as pdfrom fairlearn.metrics import (    MetricFrame, demographic_parity_difference, equalized_odds_difference)from sklearn.linear_model import LogisticRegressionfrom sklearn.model_selection import train_test_split
# ── Simulate a dataset with a protected attribute ─────────────────────────────np.random.seed(42)n = 2000group = np.random.binomial(1, 0.4, n)  # protected attribute A ∈ {0, 1}
# Features correlated with group (simulating historical bias)X = np.column_stack([    np.random.randn(n),                           # feature 1    np.random.randn(n),                           # feature 2    group + np.random.randn(n) * 0.5,             # feature correlated with group])
# Labels: base rates differ by group (group 1 has higher base rate)base_rate = np.where(group == 0, 0.2, 0.35)y = np.random.binomial(1, base_rate)
X_train, X_test, y_train, y_test, group_train, group_test = train_test_split(    X, y, group, test_size=0.3, random_state=42)
# ── Train an unconstrained classifier ────────────────────────────────────────clf = LogisticRegression(max_iter=1000, random_state=42)clf.fit(X_train, y_train)y_pred = clf.predict(X_test)
# ── Evaluate fairness metrics ─────────────────────────────────────────────────from sklearn.metrics import accuracy_score, precision_score, recall_score
mf = MetricFrame(    metrics={        "accuracy":  accuracy_score,        "precision": precision_score,        "recall":    recall_score,    },    y_true=y_test,    y_pred=y_pred,    sensitive_features=group_test,)
print("Per-group metrics:")print(mf.by_group.round(3))
print(f"\nOverall accuracy:       {accuracy_score(y_test, y_pred):.3f}")print(f"Demographic parity diff: {demographic_parity_difference(y_test, y_pred, sensitive_features=group_test):.3f}")print(f"Equalized odds diff:     {equalized_odds_difference(y_test, y_pred, sensitive_features=group_test):.3f}")

Watch Out For

Proxy discrimination through correlated features

Removing the protected attribute (race, gender) from the feature set does not remove discrimination if other features are correlated with it. Zip codes, names, and many behavioral features are strong proxies for race and ethnicity. "Fairness through unawareness" — simply dropping the protected attribute — is one of the least effective fairness interventions.

Fairness theater: measuring without acting

Publishing a fairness audit without changing the model or the decision process is fairness theater. Measuring disparities is the beginning of the process, not the end. After measuring, choose which fairness criterion your use case requires (this is a value judgment, not a technical one), apply a mitigation strategy (pre-processing, in-processing, or post-processing), and re-evaluate.

The Quick Version

  • Multiple mathematical definitions of fairness exist (demographic parity, equalized odds, calibration) — each reflects different values.
  • The impossibility theorem: when base rates differ across groups, you cannot simultaneously satisfy all fairness criteria — you must choose.
  • Removing protected attributes doesn't eliminate bias; proxy features carry the same signal.
  • Fairlearn, AIF360, and similar tools make fairness measurement practical.
  • Fairness is a socio-technical problem: measurement and mitigation are necessary but not sufficient without process and accountability changes.