Fairness, privacy and accessibility
Measure more than aggregate accuracy
Fairness evaluation asks whether system behavior creates or perpetuates harmful disparities in its context. In the synthetic learning-center example, the positive class means a request truly needs a staff follow-up; the predicted positive class means the simulated router suggests staff follow-up. TP is a correctly suggested follow-up, FP an unnecessary suggestion, TN a correctly suggested self-service answer, and FN a missed follow-up. These are fictional labels established independently of the simulated router, not characteristics of real people. Selection rate = (TP+FP)/total; false-positive rate = FP/(FP+TN); false-negative rate = FN/(FN+TP); accuracy = (TP+TN)/total. A missing denominator is undefined, not zero. Fractions make the example exact. Cohort A and B both have selection rate 1/2, but A has FPR and FNR 1/5 and B has both 2/5. Accuracy is 4/5 versus 3/5. Equal selection does not imply equal error rates. Inspect counts, denominators, uncertainty and the actual harm of errors.
from fractions import Fraction
def rates(tp, fp, tn, fn): if any(type(x) is not int or x < 0 for x in (tp, fp, tn, fn)): raise ValueError("counts must be nonnegative integers") def ratio(a, b): return Fraction(a, b) if b else None return {"selection": ratio(tp+fp, tp+fp+tn+fn), "fpr": ratio(fp, fp+tn), "fnr": ratio(fn, fn+tp), "accuracy": ratio(tp+tn, tp+fp+tn+fn)}
for name, counts in [("A", (8, 2, 8, 2)), ("B", (6, 4, 6, 4))]: print(name, {k: str(v) for k, v in rates(*counts).items()})print(rates(0, 0, 0, 0))Understand tradeoffs and evidence limits
Demographic parity compares selection rates; equal opportunity compares true-positive rates (1 minus FNR when defined); equalized odds compares true-positive and false-positive rates across groups. No one criterion guarantees fairness, and criteria can conflict, particularly when underlying label prevalence differs. Labels may reflect unequal access to services or historical decisions, so even apparently accurate labels require review. Features such as location, device or language can act as proxies for sensitive attributes; removing an explicit group field does not eliminate proxy effects. Do not use this lesson to select people for benefits or automatically set group-specific thresholds. Use authorized, purpose-limited cohort data for an independent audit, report sample sizes and missing groups, avoid revealing small cells, and compare a non-AI baseline. Where estimates are unstable, collect appropriate evidence only with permission, or abstain from a conclusion. Chapter 47 explains intervals and uncertainty.
Minimize data before model access
Data minimization means collecting and retaining what the documented purpose requires, not everything that might someday be useful. For the fictional routing task, only case_id and topic are necessary; the example projects those fields into a new dictionary and excludes address and notes. Missing or blank required fields raise ValueError rather than sending the full record as fallback. This is a narrow top-level allowlist, not anonymization: identifiers and free-text topics may still reveal personal information. Constrain inputs, redact and restrict logs, separate audit attributes from inference data, verify access, define retention and deletion, and review changes in purpose. The EU GDPR and UK GDPR have data minimization principles; the UK ICO notes its guidance is under review. Applicability and lawful basis depend on jurisdiction and the actual processing, and must be researched with qualified counsel. The local example proves neither anonymization nor legal compliance.
def minimal_ticket(record): # Only these fields are required for the fictional routing purpose. allowed = ("case_id", "topic") if any(not isinstance(record.get(k), str) or not record[k].strip() for k in allowed): raise ValueError("missing required routing field") return {k: record[k] for k in allowed}
print(minimal_ticket({"case_id":"T7", "topic":"hours", "address":"fictional address", "notes":"extra"}))Design accessible review and correction
Accessibility is a requirement for the entire service, not only generated text. Use plain language, semantic headings, keyboard navigation, visible focus, accessible form labels and clear text errors. Provide a text alternative to audio or visual-only instructions and an alternate human channel. W3C WCAG 2.2 success criteria 3.3.1 and 3.3.2 address identifying input errors and providing labels or instructions. These are examples, not the full standard. Test actual interfaces with assistive technology and affected users, including whether a person can find and complete an appeal without needing to use the AI. Avoid disclosing cohort membership or private evidence in messages to unrelated users. Track appeal completion and correction quality using approved, minimal data, not disability inference. Assign a reviewer responsible for correcting an inaccessible or wrong routing suggestion.
Practice: compare harms and propose review
Use the two synthetic cohorts and add an empty cohort. Calculate selection, FPR, FNR and accuracy with denominators and explain why equal selection is insufficient. Compare with a fictional baseline that always suggests human review: FNR zero where positives exist, FPR one where negatives exist, and increased staff burden. Neither policy is automatically preferable; assess missed follow-up, waiting time and availability of a human channel. Project T7 into the minimal payload; try a missing topic and describe safe correction. Submit an accessible appeal form sketch with clear labels and text errors, an independent review plan, and explicit NOT RUN entries for legal, real accessibility and fairness checks. Reference: ref-ai-fairness-privacy-and-accessibility. Next chapter: data governance and lifecycle.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Fairness, privacy and accessibility quiz
Assess governance, meaningful oversight, cohort error metrics and privacy.
Which denominator defines the false-negative rate?
Both cohorts have selection rate 1/2 but FNR differs. What follows?
What should a rate with a zero denominator represent?
Does omitting an explicit group attribute eliminate proxy bias?
Which action best supports accessible recourse and privacy?