smartyfy.mrindigi.com

AI & Machine Learning Master Course — 173. Fairness definitions and trade-offs

Smartyfy AI & Machine Learning Master Course

Course ID: smartyfy-ai-ml-master-200

Lesson 173: Fairness definitions and trade-offs

Prerequisites: Lesson 172. Learning outcome: Compare group metrics, applicability, and incompatible objectives without universal claims.

Fairness begins with a context and a harm model

Fairness evaluation asks how a system’s benefits, errors, burdens, and opportunities are distributed in a particular application. A numerical metric can illuminate one part of that question, but it cannot choose the relevant values or settle every trade-off by itself.

Define the decision, affected population, outcome label, error costs, and groups or intersections that matter. The meaning of a positive prediction depends on the task: it might represent a useful alert, an unwanted interruption, or access to something valuable. The same numerical disparity can have different consequences in different contexts.

This lesson uses anonymous fictional groups A and B and aggregate confusion counts. It does not make decisions about actual people or identify a legally sufficient fairness standard. The aim is to calculate several definitions and understand why they can disagree.

Several definitions condition on different quantities

Demographic parity compares positive prediction or selection rates across groups, without conditioning on the observed outcome label. Equal opportunity, in the binary positive-outcome formulation, compares true-positive rates. Equalized odds requires equality of both true-positive and false-positive rates.

Predictive parity compares precision, also called positive predictive value: among positive predictions, what fraction has a positive reference label? This conditions on the prediction rather than on the true label, so it is not the same denominator as true-positive rate.

Calibration concerns the interpretation of probabilistic scores. Within a group, a calibrated score level corresponds to the observed positive-outcome frequency at that level. A confusion matrix at one threshold does not establish score calibration. Do not infer it merely because two groups have the same accuracy or precision.

These are statistical definitions, not complete ethical verdicts. The reference labels may themselves reflect measurement errors, historical exclusion, or unequal observation. Matching metrics against a biased label process can preserve rather than resolve underlying problems.

CPU lab: equal error rates with unequal precision

Group A has fifty positive and fifty negative reference labels. Its counts are forty true positives, ten false negatives, ten false positives, and forty true negatives. Group B has twenty positives and eighty negatives, with counts sixteen, four, sixteen, and sixty-four respectively.

Both groups have true-positive rate 0.8, false-positive rate 0.2, and accuracy 0.8. Thus the displayed threshold satisfies equalized odds and the stated equal-opportunity criterion on these exact fixtures.

However, A’s selection rate is 0.5 and B’s is 0.32. Precision is 0.8 for A and 0.5 for B. Demographic parity and predictive parity therefore do not hold on the same counts. Run the standard-library calculation to verify each denominator.

These are invented aggregate counts, not fitted model outputs or an audit of a real institution. They demonstrate simultaneous metric relationships without choosing which definition should govern an actual decision.

# Synthetic aggregate confusion counts, not decisions about real people.
groups={'A':{'tp':40,'fn':10,'fp':10,'tn':40},
        'B':{'tp':16,'fn':4,'fp':16,'tn':64}}
results={}
for name,c in groups.items():
    tp,fn,fp,tn=(c[k] for k in ['tp','fn','fp','tn']);n=tp+fn+fp+tn
    results[name]={'prevalence':(tp+fn)/n,'selection':(tp+fp)/n,
                   'tpr':tp/(tp+fn),'fpr':fp/(fp+tn),
                   'precision':tp/(tp+fp),'accuracy':(tp+tn)/n}
    print(name,results[name])
assert results['A']['tpr']==results['B']['tpr']==.8
assert results['A']['fpr']==results['B']['fpr']==.2
assert results['A']['precision']==.8 and results['B']['precision']==.5
print('Equal TPR/FPR but unequal precision and selection:',True)

Compare the fixture metrics

Different fairness definitions on the same synthetic counts
Quantity Group A Group B
Reference-label prevalence 0.50 0.20
Selection rate 0.50 0.32
True-positive rate 0.80 0.80
False-positive rate 0.20 0.20
Precision 0.80 0.50

Derive the denominator trade-off

Let prevalence be pi, true-positive rate be t, and false-positive rate be f. Per unit population, true positives have mass t times pi and false positives have mass f times (1-pi). Precision is therefore t*pi divided by [t*pi + f*(1-pi)], when the denominator is positive.

For A, substitute t=0.8, f=0.2, pi=0.5. The numerator is 0.4 and denominator 0.5, giving 0.8. For B, the numerator is 0.16 and denominator 0.32, giving 0.5. Equal conditional error rates do not erase the different base rates in this formula.

Under differing prevalences and nondegenerate positive error rates, requiring equalized odds can conflict with equal precision. Special cases, such as perfect prediction, need separate treatment. Broader impossibility results have precise assumptions; do not shorten them to “fairness is impossible” or “all fairness metrics always conflict.”

The practical lesson is to explain the chosen criterion and its consequences. A threshold change can alter error trade-offs and utility. It should be evaluated with domain context, stakeholder input, and appropriate policy review rather than selected solely to make one dashboard gap disappear.

Build a responsible audit beyond aggregate averages

Report counts and uncertainty alongside rates. A zero estimated error rate from a tiny group is not strong evidence that its population error is zero. For repeated observations, account for dependence at the relevant unit. Inspect intersections where aggregate group results may hide problems.

Removing a group attribute from model inputs does not guarantee fairness. Other features can act as proxies, labels can be biased, and unequal access can arise elsewhere in the workflow. Conversely, measuring disparities may require appropriately governed group information that should not be collected or exposed casually.

Evaluate data collection, label quality, missingness, thresholds, human review, and downstream outcomes. Distinguish predictive performance from the consequences of the decisions built around it. Document who can raise concerns and how errors can be corrected.

The lab’s useful output is a transparent set of calculations and a denominator-based explanation of their disagreement. It is not a universal ranking of fairness definitions or a certification that a system is acceptable.

Four practice questions with worked answers

Practice 1

Compute group B’s true-positive rate and precision.

Answer: True-positive rate is 16/(16+4)=0.8. Precision is 16/(16+16)=0.5. The first denominator contains reference positives; the second contains predicted positives.

Practice 2

Why do equal true-positive and false-positive rates not imply equal selection rates here?

Answer: Selection rate is t*pi + f*(1-pi). With different prevalences, the same t and f combine with different population masses. The results are 0.5 and 0.32.

Practice 3

Can these thresholded counts prove within-group probability calibration?

Answer: No. Calibration requires information about score values and outcome frequencies at those values. A single confusion matrix discards that score-level detail.

Practice 4

Why report group counts as well as rates?

Answer: Rates based on few observations have greater sampling uncertainty, and some denominators may be zero. Counts also reveal which cases contribute to each metric and help prevent misleading comparisons.

Five multiple-choice questions

Question 1

Which denominator defines true-positive rate?

  • A. All positive reference labels in the group.
  • B. Every member of the group regardless of label.
  • C. All positive predictions in the group.

Correct: A. TPR is true positives divided by true positives plus false negatives. Precision and selection rate use different denominators.

Question 2

Which stated criterion holds in the fixture?

  • A. Equalized odds at the displayed threshold.
  • B. Predictive parity.
  • C. Demographic parity.

Correct: A. TPR and FPR match across groups, while selection rates and precision differ.

Question 3

What explains the precision difference despite equal TPR and FPR?

  • A. Equalized odds requires different true-positive rates by definition.
  • B. Precision is mathematically identical to accuracy in every group.
  • C. Different reference-label prevalences enter the precision denominator.

Correct: C. Bayes’ rule links precision to prevalence as well as conditional error rates.

Question 4

Which statement about removing a group attribute is correct?

  • A. Every proxy for that attribute is automatically removed too.
  • B. All group error rates necessarily become equal.
  • C. It does not by itself guarantee fair outcomes.

Correct: C. Proxies, label processes, and downstream decisions can preserve disparities even without the explicit attribute.

Question 5

What conclusion about fairness trade-offs is justified?

  • A. One aggregate metric can certify every ethical and legal requirement.
  • B. Some criteria conflict under specified distributional conditions, so assumptions and context matter.
  • C. Every fairness definition is incompatible with every other in all datasets.

Correct: B. Trade-off results have conditions and exceptions. Metrics illuminate specific questions rather than replacing contextual judgment.

Common pitfalls

Avoid mixing precision with true-positive rate, inferring calibration from one threshold, hiding small denominators, or presenting conditional impossibility results as universal defeat. Treat metric choice as a contextual decision.

Summary

Fairness metrics condition on different populations and can disagree even when accuracy matches. A responsible audit explains denominators, uncertainty, label limitations, and the consequences of the chosen criteria.

Primary sources and further reading