Skip to content

You can't have every kind of fair

When base rates differ, the definitions of fair can't all hold at once. See the arithmetic, see what each constraint costs on real runs, and practice saying which harm you chose to reduce and why.

Advanced ~15 min10 steps

What runs in CodeSplash

You will be able to

  • Show why equal error rates and predictive parity can't all hold when base rates differ
  • Read what a fairness constraint changes, and what it costs
  • Explain why removing the sensitive attribute doesn't fix unfairness
  • Justify the fairness definition you choose

Read first

01

All of them at once?

Predict

Predict first

Two groups repay at different rates. You'd like the same precision and the same true-positive and false-positive rates in both. Can you have all of that?

Yes, with a good enough modelOnly with equal base rates or a perfect modelNo model can ever do any of them
Reveal

Only with equal base rates or a perfect model. This is arithmetic, not a shortcoming of any model. Chouldechova (2017) and Kleinberg and colleagues (2017) showed it for different versions of the same problem.

02

The arithmetic

Checkpoint

Same precision, same misses, different base rates

These rates are tied together, with base rate bb:

FPR=b1−b⋅1−PPVPPV⋅(1−FNR)\text{FPR} = \frac{b}{1-b} \cdot \frac{1-\text{PPV}}{\text{PPV}} \cdot (1-\text{FNR})
  1. Hold PPV=0.8\text{PPV} = 0.8 and FNR=0.2\text{FNR} = 0.2 in both groups.
  2. With b=0.5b = 0.5: FPR=1×0.25×0.8=0.20\text{FPR} = 1 \times 0.25 \times 0.8 = 0.20.
  3. With b=0.2b = 0.2: FPR=0.25×0.25×0.8=0.05\text{FPR} = 0.25 \times 0.25 \times 0.8 = 0.05.
  4. Try this step yourself, then reveal it
    The false-positive rates must differ, four to one.

Check yourself

Same PPV and FNR. Now the base rate is b=1/3b = 1/3. What must the FPR be?

Show the answer

Answer: 0.1

1/32/3=0.5\frac{1/3}{2/3} = 0.5, and 0.5×0.25×0.8=0.100.5 \times 0.25 \times 0.8 = 0.10.

03

What a constraint changes

Read

These are the simulated credit decisions again, with a different threshold for each group chosen to meet a constraint at the lowest cost.

Selection gapTPR gapFPR gapErrors per decision
One threshold, 0.50.2880.2840.2050.318
Demographic parity0.0000.0110.0870.303
Equalized odds0.0440.0000.0000.312

Closing one gap leaves others open, and each row is a choice about which ones matter.

Fair decision thresholdsRecorded · Python and R agreeRecorded 2026-11-17 · 24 values compared
R

Under demographic parity, the best group thresholds give an expected errors of 0.303 per decision, against 0.291 when each group gets its own best threshold and 0.318 for one threshold of 0.5. Selection rates after: A 64.8%, B 64.8%, C 64.8%.

Expected errors per decision (fair)
0.3026
Each group's own best
0.2905
One threshold (0.5)
0.3176

Plots

Rates by group: one threshold vs fair thresholdsDo a model's decisions or error rates differ across groups, and by how much?
View data
groupMetricRate
ASelection (one threshold)0.5756
ASelection (fair)0.6481
ATPR (one threshold)0.7336
ATPR (fair)0.8107
BSelection (one threshold)0.3720
BSelection (fair)0.6481
BTPR (one threshold)0.5161
BTPR (fair)0.8086
CSelection (one threshold)0.6605
CSelection (fair)0.6481
CTPR (one threshold)0.8000
CTPR (fair)0.8000

Decision rule per group

groupnRuleSelection rateTPRFPRAccuracySelection at 0.5TPR at 0.5
A476score ≥ 0.495; 0.391 ≤ score < 0.495 selected with probability 0.46164.8%81.1%42.8%71.0%57.6%73.4%
B250score ≥ 0.32; 0.218 ≤ score < 0.32 selected with probability 0.55164.8%80.9%49.0%65.8%37.2%51.6%
C162score ≥ 0.53164.8%80.0%40.3%72.2%66.0%80.0%

Disparities before and after

MetricOne threshold (0.5)Fair thresholds
Demographic parity difference0.28850
Equal opportunity difference (TPR)0.28390.0107
False-positive rate difference0.20530.0870
  • 12 of 900 rows were left out because a value was missing.
  • Cost per decision = (1 × false negatives + 1 × false positives) / n, expected over the randomization. Solved exactly over the lower convex hull of each group's operating points.
  • Group-specific thresholds use the group attribute at decision time; check that this is lawful and acceptable for your decision before using them.
The exact R script · R R version 4.5.1 (2025-06-13)
# Fair decision thresholds (post-processing)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method fairness.threshold 1.0.1 · spec 075c92e5d6ac479a
# Dataset: o2_credit (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr) # cs_fair_thresholds(): twin of codesplash.decide.fairness (exact hull search; HiGHS LP via the highs package)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/o2_credit.parquet", col_select = c("group", "repaid", "score")))
n_input <- nrow(df)
df[["group"]] <- factor(df[["group"]], levels = c("A", "B", "C"))  # stored level order
df[["repaid"]] <- factor(df[["repaid"]], levels = c("false", "true"))  # stored level order
df <- df[stats::complete.cases(df[c("group", "repaid", "score")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("group", "repaid", "score"))  # infinite values stop the run (registry/errors.yaml)

# %% Inputs
g_col <- "group"
y_col <- "repaid"
s_col <- "score"
constraint <- "demographic_parity"
tolerance <- 0
cost_fp <- 1
cost_fn <- 1
capacity <- NULL # NULL = no limit
baseline <- 0.5
group_levels <- levels(df[[g_col]])
group <- as.character(df[[g_col]])
score <- as.numeric(df[[s_col]])
if (is.factor(df[[y_col]])) {
  ycats <- levels(df[[y_col]])
  y_pos <- ycats[length(ycats)] # default: the second stored level
  y <- as.numeric(as.character(df[[y_col]]) == y_pos)
} else {
  y <- as.numeric(df[[y_col]])
  if (!all(y %in% c(0, 1))) stop(sprintf("%s must be 0/1 (or yes/no).", y_col))
}
n <- length(y)

# %% Thresholds
fair <- cs_fair_thresholds(group, y, score, group_levels, constraint, cost_fp = cost_fp, cost_fn = cost_fn, capacity = capacity, tolerance = tolerance)
free <- cs_fair_thresholds(group, y, score, group_levels, "none", cost_fp = cost_fp, cost_fn = cost_fn)
lv_all <- fair$levels
# A single shared threshold for comparison.
pred0 <- as.numeric(score >= baseline)
cost_baseline <- sum(cost_fn * (pred0 == 0 & y == 1) + cost_fp * (pred0 == 1 & y == 0)) / n
base <- cs_fair_group_metrics(group, pred0, y, NULL, lv_all, boot = 0)
after_disp <- cs_fair_disparities(lapply(stats::setNames(lv_all, lv_all), function(lv) {
  a <- fair$groups[[lv]]
  list(selection = a$selection, tpr = a$tpr, fpr = a$fpr, accuracy = a$accuracy, ppv = NaN)
}))

rule <- function(mixture) {
  pts <- Filter(function(p) p[2] > 0, mixture)
  if (length(pts) == 1) {
    t <- pts[[1]][1]
    return(if (is.infinite(t)) "nobody selected" else sprintf("score ≥ %s", format(t)))
  }
  if (length(pts) == 2) {
    o <- pts[order(-vapply(pts, function(p) p[1], numeric(1)))]
    t_hi <- o[[1]][1]
    t_lo <- o[[2]][1]
    w_lo <- o[[2]][2]
    if (is.infinite(t_hi)) return(sprintf("score ≥ %s selected with probability %.3f", format(t_lo), w_lo))
    return(sprintf("score ≥ %s; %s ≤ score < %s selected with probability %.3f", format(t_hi), format(t_lo), format(t_hi), w_lo))
  }
  paste("randomized mixture of", paste(vapply(pts, function(p) sprintf("score ≥ %s (weight %.3f)", format(p[1]), p[2]), ""), collapse = ", "))
}

# %% Result
labels <- c(demographic_parity = "demographic parity", equal_opportunity = "equal opportunity", equalized_odds = "equalized odds", none = "no constraint")
unit <- if (cost_fp == 1 && cost_fn == 1) "errors" else "cost"
summary <- paste0(
  "Under ", labels[[constraint]], if (tolerance > 0) sprintf(" (± %s)", format(tolerance)) else "",
  if (!is.null(capacity)) sprintf(" with at most %.0f%% selected", 100 * capacity) else "",
  sprintf(", the best group thresholds give an expected %s of %.3f per decision, against %.3f when each group gets its own best threshold and %.3f for one threshold of %s. Selection rates after: ",
          unit, fair$cost, free$cost, cost_baseline, format(baseline)),
  paste(vapply(lv_all, function(lv) sprintf("%s %.1f%%", lv, 100 * fair$groups[[lv]]$selection), ""), collapse = ", "), "."
)
values <- list(cost = fair$cost, cost_unconstrained = free$cost, cost_baseline = cost_baseline, price_of_fairness = fair$cost - free$cost,
               solver = fair$solver, n = n)
rows <- do.call(rbind, lapply(lv_all, function(lv) {
  a <- fair$groups[[lv]]
  b <- base$groups[[lv]]
  data.frame(group = lv, n = a$n, rule = rule(a$mixture), selection = a$selection, tpr = a$tpr, fpr = a$fpr, accuracy = a$accuracy,
             selection_before = b$selection, tpr_before = b$tpr)
}))
for (lv in lv_all) for (k in c("selection", "tpr", "fpr", "accuracy")) values[[sprintf("%s[%s]", k, lv)]] <- fair$groups[[lv]][[k]]
for (k in c("dp_diff", "eop_diff", "fpr_diff")) {
  values[[paste0(k, "_after")]] <- after_disp[[k]]
  values[[paste0(k, "_before")]] <- base$disparities[[k]]
}
metric_names <- c("Selection (one threshold)", "Selection (fair)", "TPR (one threshold)", "TPR (fair)")
cs_publish(list(
  method = "fairness.threshold",
  methodVersion = "1.0.1",
  title = "Fair decision thresholds",
  engine = cs_engine_info("stats", "highs", "codesplashr"),
  n = n,
  summary = summary,
  statistics = list(
    list(key = "cost", label = sprintf("Expected %s per decision (fair)", unit), value = fair$cost),
    list(key = "cost_unconstrained", label = "Each group's own best", value = free$cost),
    list(key = "cost_baseline", label = sprintf("One threshold (%s)", format(baseline)), value = cost_baseline)
  ),
  tables = list(
    list(key = "thresholds", title = "Decision rule per group",
         columns = list(list(key = "group", label = g_col, type = "string"), list(key = "n", label = "n", type = "integer"),
                        list(key = "rule", label = "Rule", type = "string"), list(key = "selection", label = "Selection rate", type = "percent"),
                        list(key = "tpr", label = "TPR", type = "percent"), list(key = "fpr", label = "FPR", type = "percent"),
                        list(key = "accuracy", label = "Accuracy", type = "percent"),
                        list(key = "selection_before", label = sprintf("Selection at %s", format(baseline)), type = "percent"),
                        list(key = "tpr_before", label = sprintf("TPR at %s", format(baseline)), type = "percent")),
         rows = rows),
    list(key = "disparities", title = "Disparities before and after",
         columns = list(list(key = "metric", label = "Metric", type = "string"), list(key = "before", label = sprintf("One threshold (%s)", format(baseline)), type = "number"),
                        list(key = "after", label = "Fair thresholds", type = "number")),
         rows = data.frame(metric = c("Demographic parity difference", "Equal opportunity difference (TPR)", "False-positive rate difference"),
                           before = c(base$disparities$dp_diff, base$disparities$eop_diff, base$disparities$fpr_diff),
                           after = c(after_disp$dp_diff, after_disp$eop_diff, after_disp$fpr_diff)))
  ),
  warnings = warnings,
  notes = list(
    paste0(sprintf("Cost per decision = (%s × false negatives + %s × false positives) / n, expected over the randomization. ", format(cost_fn), format(cost_fp)),
           if (fair$solver == "exact") "Solved exactly over the lower convex hull of each group's operating points." else "Solved as a linear program (HiGHS)."),
    "Group-specific thresholds use the group attribute at decision time; check that this is lawful and acceptable for your decision before using them."
  ),
  values = values,
  charts = list(cs_chart("rates", "group-metrics", sprintf("Rates by %s: one threshold vs fair thresholds", g_col), list(
    group = cs_col(g_col, rep(lv_all, each = 4), levels = lv_all),
    metric = cs_col("Metric", rep(metric_names, times = length(lv_all)), levels = metric_names),
    value = cs_col("Rate", unlist(lapply(lv_all, function(lv) c(base$groups[[lv]]$selection, fair$groups[[lv]]$selection,
                                                                   base$groups[[lv]]$tpr, fair$groups[[lv]]$tpr))))
  ), controls = list(reference = NA, band_low = 0, band_high = 0)))
))
Python

Under demographic parity, the best group thresholds give an expected errors of 0.303 per decision, against 0.291 when each group gets its own best threshold and 0.318 for one threshold of 0.5. Selection rates after: A 64.8%, B 64.8%, C 64.8%.

Expected errors per decision (fair)
0.3026
Each group's own best
0.2905
One threshold (0.5)
0.3176

To keep this page light, the plots are shown once, under the R tab.

Decision rule per group

groupnRuleSelection rateTPRFPRAccuracySelection at 0.5TPR at 0.5
A476score ≥ 0.495; 0.391 ≤ score < 0.495 selected with probability 0.46164.8%81.1%42.8%71.0%57.6%73.4%
B250score ≥ 0.32; 0.218 ≤ score < 0.32 selected with probability 0.55164.8%80.9%49.0%65.8%37.2%51.6%
C162score ≥ 0.53164.8%80.0%40.3%72.2%66.0%80.0%

Disparities before and after

MetricOne threshold (0.5)Fair thresholds
Demographic parity difference0.28850
Equal opportunity difference (TPR)0.28390.0107
False-positive rate difference0.20530.0870
  • 12 of 900 rows were left out because a value was missing.
  • Cost per decision = (1 × false negatives + 1 × false positives) / n, expected over the randomization. Solved exactly over the lower convex hull of each group's operating points.
  • Group-specific thresholds use the group attribute at decision time; check that this is lawful and acceptable for your decision before using them.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Fair decision thresholds (post-processing)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method fairness.threshold 1.0.1 · spec 075c92e5d6ac479a
# Dataset: o2_credit (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.decide import fairness  # twin of codesplashr::cs_fair_thresholds (exact hull search; HiGHS LP)

# %% Data
df = pd.read_parquet("tests/parity/fixtures/o2_credit.parquet", columns=["group", "repaid", "score"])
n_input = len(df)
df["group"] = pd.Categorical(df["group"], categories=["A", "B", "C"])  # stored level order
df["repaid"] = pd.Categorical(df["repaid"], categories=["false", "true"])  # stored level order
df = df.dropna(subset=["group", "repaid", "score"])  # listwise deletion over the analysis columns
df["group"] = df["group"].cat.remove_unused_categories()
df["repaid"] = df["repaid"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["group", "repaid", "score"])  # infinite values stop the run (registry/errors.yaml)

# %% Inputs
g_col, y_col, s_col = "group", "repaid", "score"
constraint = "demographic_parity"
tolerance = 0
cost_fp, cost_fn = 1, 1
capacity = None  # None = no limit
baseline = 0.5
group_levels = [str(x) for x in df[g_col].cat.categories]
group = df[g_col].astype(str).to_numpy()
score = df[s_col].to_numpy(dtype=float)
if isinstance(df[y_col].dtype, pd.CategoricalDtype):
    ycats = [str(x) for x in df[y_col].cat.categories]
    y_pos = ycats[-1]  # default: the second stored level
    y = (df[y_col].astype(str) == y_pos).to_numpy(dtype=float)
else:
    y = df[y_col].to_numpy(dtype=float)
    if not np.isin(y, [0.0, 1.0]).all():
        raise ValueError(f"{y_col} must be 0/1 (or yes/no).")
n = len(y)

# %% Thresholds
fair = fairness.thresholds(group, y, score, group_levels, constraint, cost_fp=cost_fp, cost_fn=cost_fn, capacity=capacity, tolerance=tolerance)
free = fairness.thresholds(group, y, score, group_levels, "none", cost_fp=cost_fp, cost_fn=cost_fn)
levels = fair["levels"]
# A single shared threshold for comparison.
pred0 = (score >= baseline).astype(float)
cost_baseline = float((cost_fn * ((pred0 == 0) & (y == 1)) + cost_fp * ((pred0 == 1) & (y == 0))).sum() / n)
base = fairness.group_metrics(group, pred0, y, None, levels, boot=0)
after_disp = fairness.disparities({lv: {k: fair["groups"][lv][k] for k in ("selection", "tpr", "fpr", "accuracy")} | {"ppv": float("nan")} for lv in levels})


def rule(mixture):
    pts = [(t, w) for t, w in mixture if w > 0]
    if len(pts) == 1:
        t = pts[0][0]
        return "nobody selected" if np.isinf(t) else f"score ≥ {t:g}"
    if len(pts) == 2:
        (t_hi, _), (t_lo, w_lo) = sorted(pts, key=lambda p: -p[0])
        hi_text = "nobody for sure" if np.isinf(t_hi) else f"score ≥ {t_hi:g}"
        return f"{hi_text}; {t_lo:g} ≤ score < {t_hi:g} selected with probability {w_lo:.3f}" if not np.isinf(t_hi) else f"score ≥ {t_lo:g} selected with probability {w_lo:.3f}"
    return "randomized mixture of " + ", ".join(f"score ≥ {t:g} (weight {w:.3f})" for t, w in pts)


# %% Result
labels = {"demographic_parity": "demographic parity", "equal_opportunity": "equal opportunity", "equalized_odds": "equalized odds", "none": "no constraint"}
unit = "errors" if cost_fp == cost_fn == 1 else "cost"
summary = (
    f"Under {labels[constraint]}" + (f" (± {tolerance:g})" if tolerance else "") + (f" with at most {capacity:.0%} selected" if capacity is not None else "")
    + f", the best group thresholds give an expected {unit} of {fair['cost']:.3f} per decision, against {free['cost']:.3f} when each group gets its own best "
    f"threshold and {cost_baseline:.3f} for one threshold of {baseline:g}. Selection rates after: "
    + ", ".join(f"{lv} {fair['groups'][lv]['selection']:.1%}" for lv in levels) + "."
)
rows = []
values = {"cost": fair["cost"], "cost_unconstrained": free["cost"], "cost_baseline": cost_baseline, "price_of_fairness": fair["cost"] - free["cost"],
          "solver": fair["solver"], "n": n}
for lv in levels:
    a, b = fair["groups"][lv], base["groups"][lv]
    rows.append({"group": lv, "n": a["n"], "rule": rule(a["mixture"]), "selection": a["selection"], "tpr": a["tpr"], "fpr": a["fpr"],
                 "accuracy": a["accuracy"], "selection_before": b["selection"], "tpr_before": b["tpr"]})
    for k in ("selection", "tpr", "fpr", "accuracy"):
        values[f"{k}[{lv}]"] = a[k]
for k in ("dp_diff", "eop_diff", "fpr_diff"):
    values[f"{k}_after"] = after_disp[k]
    values[f"{k}_before"] = base["disparities"][k]
cs.publish({
    "method": "fairness.threshold",
    "methodVersion": "1.0.1",
    "title": "Fair decision thresholds",
    "engine": cs.engine_info("numpy", "pandas", "scipy"),
    "n": n,
    "summary": summary,
    "statistics": [
        {"key": "cost", "label": f"Expected {unit} per decision (fair)", "value": fair["cost"]},
        {"key": "cost_unconstrained", "label": "Each group's own best", "value": free["cost"]},
        {"key": "cost_baseline", "label": f"One threshold ({baseline:g})", "value": cost_baseline},
    ],
    "tables": [
        {"key": "thresholds", "title": "Decision rule per group",
         "columns": [{"key": "group", "label": g_col, "type": "string"}, {"key": "n", "label": "n", "type": "integer"},
                     {"key": "rule", "label": "Rule", "type": "string"}, {"key": "selection", "label": "Selection rate", "type": "percent"},
                     {"key": "tpr", "label": "TPR", "type": "percent"}, {"key": "fpr", "label": "FPR", "type": "percent"},
                     {"key": "accuracy", "label": "Accuracy", "type": "percent"}, {"key": "selection_before", "label": f"Selection at {baseline:g}", "type": "percent"},
                     {"key": "tpr_before", "label": f"TPR at {baseline:g}", "type": "percent"}],
         "rows": rows},
        {"key": "disparities", "title": "Disparities before and after",
         "columns": [{"key": "metric", "label": "Metric", "type": "string"}, {"key": "before", "label": f"One threshold ({baseline:g})", "type": "number"},
                     {"key": "after", "label": "Fair thresholds", "type": "number"}],
         "rows": [{"metric": "Demographic parity difference", "before": base["disparities"]["dp_diff"], "after": after_disp["dp_diff"]},
                  {"metric": "Equal opportunity difference (TPR)", "before": base["disparities"]["eop_diff"], "after": after_disp["eop_diff"]},
                  {"metric": "False-positive rate difference", "before": base["disparities"]["fpr_diff"], "after": after_disp["fpr_diff"]}]},
    ],
    "warnings": warnings,
    "notes": [
        f"Cost per decision = ({cost_fn:g} × false negatives + {cost_fp:g} × false positives) / n, expected over the randomization. "
        + ("Solved exactly over the lower convex hull of each group's operating points." if fair["solver"] == "exact" else "Solved as a linear program (HiGHS)."),
        "Group-specific thresholds use the group attribute at decision time; check that this is lawful and acceptable for your decision before using them.",
    ],
    "values": values,
    "charts": [
        cs.chart("rates", "group-metrics", f"Rates by {g_col}: one threshold vs fair thresholds", {
            "group": cs.col(g_col, [lv for lv in levels for _ in range(4)], levels=levels),
            "metric": cs.col("Metric", [m for _ in levels for m in ("Selection (one threshold)", "Selection (fair)", "TPR (one threshold)", "TPR (fair)")],
                             levels=["Selection (one threshold)", "Selection (fair)", "TPR (one threshold)", "TPR (fair)"]),
            "value": cs.col("Rate", [v for lv in levels for v in (base["groups"][lv]["selection"], fair["groups"][lv]["selection"],
                                                                  base["groups"][lv]["tpr"], fair["groups"][lv]["tpr"])]),
        }, controls={"reference": None, "band_low": 0, "band_high": 0}),
    ],
})
04

What did it cost?

Predict

Predict first

Compare one shared threshold with the demographic parity row above. What happens to errors?

Errors rise, as fairness always costs accuracyErrors fallErrors stay exactly the same
Reveal

Here they fall, from 0.318 to 0.303, because the shared threshold was treating an understated score as if it meant the same thing for everyone. The price of fairnessPrice of fairnessHow much decision cost rises when you add a fairness constraint, compared with the best unconstrained thresholds. is measured against each group's own best threshold, 0.291: that's 0.012 here, and 0.021 for equalized odds. Fairness and accuracy don't always pull apart.

05

Delete the column?

Checkpoint

A common first idea is to remove the sensitive attribute from the model. Other columns can carry the same information, so a proxyProxy variableA column that carries much of the same information as another, such as postcode standing in for income. such as postcode or employment gap can rebuild it. Removing the column also means you can no longer measure the gap.

Check yourself

A team removes gender from a hiring model and reports that the model is now fair. What should you ask?

Show the answer

Answer: b

Fairness is a property of the decisions, not of the input list. To audit it, you need the attribute on hand, even if the model never uses it.

06

Group thresholds have a problem too

Read

Thresholds that differ by group use the sensitive attribute at the moment of decision. In some settings that may be unlawful, including areas of lending and hiring in some countries, even when the goal is fairer outcomes. CodeSplash can't tell you what applies to you, so ask someone who can.

There are usually other options too. Recalibrate the score, as the flaw here was in the score. Get better data for the group it fails. Change what the decision is based on, or how it can be appealed. Thresholds treat the symptom, and the cause may still be there.

07

Choose by harm

Reflect

The right definition comes from who gets hurt, and how.

If the worst harm isLook first at
Qualified people wrongly refusedEqual opportunity
People wrongly flagged or punishedFalse-positive rates
Access itself being unequalDemographic parity
Scores being read differentlyCalibration

Pick a decision you know. Write two sentences: which harm you chose to reduce, and which others you accepted and why. Then ask who should have made that call, because it isn't only yours, and it isn't a statistical question.

08

Check your understanding

Checkpoint

Check yourself

A risk score is used to decide who is detained. Its precision matches across groups, but one group's false-positive rate is far higher. The vendor says it's fair because the score is calibrated. How do you respond?

Show the answer

Answer: c

Each side can be right about its own metric. The disagreement is about which harm matters, and that has to be argued in the open.

Check yourself

You run demographic parity with a tolerance of zero and a capacity limit, and errors rise well above the shared threshold's. What's the honest next step?

Show the answer

Answer: c

Constraints can be expensive, and a limited number of places makes them more so. Your job is to make that visible, and not to settle it alone.

09

See the trade-off

In the app

In the fairness audit of {{decision}} across {{group}}, open Fair thresholds. Try each option in Fairness constraint, then raise Allowed difference and set the costs of false positives and false negatives. Disparities before and after shows what moved, and Decision rule per group shows the rule each group gets.

10

Recap

Recap
  • With different base rates, equal precision and equal error rates can't all hold. You have to choose.
  • Report what a constraint changes and what it costs. Sometimes it costs less than you'd expect.
  • Removing a column doesn't remove the bias. Measure outcomes, and name the harm you chose to reduce.

Concepts in this lesson