Fairness trade-offs
Quick answer
Fairness metrics formalize different goals for decision systems. Demographic parity compares positive decision rates, equal opportunity compares true-positive rates, and equalized odds compares both true- and false-positive rates. None alone establishes that a system is fair. Examples are static Python snippets tested locally on CPU; The confusion matrix example requires scikit-learn; exercises use standard-library Python. ByteMind execution is unverified.
Perfect classifier, different prevalences
from fractions import Fractionprint(Fraction(3,4)-Fraction(1,4),1-1,0-0)Expected output (locally tested): 1/2 0 0. Selection gap is nonzero even with equalized odds.
How it works
For fictional groups A and B, demographic parity difference is max selection rate minus min selection rate. Equal opportunity difference is the analogous TPR gap. An equalized-odds difference convention is max(TPR gap,FPR gap). Other implementations may use other summaries: state the definition. A perfect classifier on groups with different positive prevalences has TPR=1 and FPR=0 in each group, but different selection rates. Therefore matching equalized odds does not generally imply demographic parity. Predictive parity compares precision, another distinct conditional rate. Calibration asks whether outcomes match estimated probabilities within a score range; different prevalences can make multiple desirable conditions incompatible except in special cases. Labels may themselves encode measurement or historical bias. Do not treat observed parity as a legal conclusion or optimize a single gap without considering outcomes, harms, access and review. In actual contexts stakeholder input and domain review determine what to measure. Here synthetic equipment families are only an arithmetic analogy. Compare both absolute rates and gaps and document who bears errors. Group-specific thresholds can change error trade-offs and may require legal and governance review in real systems; this chapter does not prescribe them.
Equal selection, unequal recall
from fractions import Fraction# Each group selects two of four rows.print(Fraction(2,4)-Fraction(2,4),Fraction(2,2)-Fraction(1,2))Expected output (locally tested): 0 1/2. Equal selection rates do not imply equal opportunity.
Common mistakes
Do not infer fairness from parity alone, use accuracy as a substitute for TPR/FPR, or assume excluding a group field eliminates proxies.
Practice and next steps
Construct two groups of four rows with respectively one and three positives. Predict perfectly and compute selection-rate and TPR gaps.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Fairness trade-offs — knowledge check
Apply fairness trade-offs to small examples and debugging scenarios.
What does demographic parity compare?
What does equalized odds compare?
Can a perfect classifier violate demographic parity?
What is predictive parity about?
Does parity prove legal or ethical fairness?