Course contentsShow
← Machine Learning and Deep Learning
Lesson 3291 of 3,53872. Bias and FairnessFree lesson

Counterfactual Fairness

Learn counterfactual fairness: decisions should be the same in the actual world and counterfactual world where protected attributes differ.

Counterfactual Fairness

What you'll learn: You'll discover how counterfactual fairness ensures decisions remain unchanged even if a person's protected attributes were different.

The Core Idea

Imagine two job applicants with identical qualifications, but one is a woman and the other is a man. Counterfactual fairness asks: "Would the woman receive the same decision if, in a counterfactual world, she had been born a man instead—keeping everything else causally influenced by gender the same?"

A model satisfies counterfactual fairness if its prediction for an individual in the actual world equals its prediction in a counterfactual world where only their protected attributes (race, gender, age, etc.) differ, but all downstream effects remain consistent with that change.

Why It Matters

Unlike demographic parity or equalized odds (which look at group-level statistics), counterfactual fairness operates at the individual level and considers causal relationships. It recognizes that protected attributes may legitimately influence outcomes through certain pathways (e.g., pregnancy affecting work schedules) while prohibiting illegitimate pathways (e.g., gender-based discrimination).

This requires building a causal model that explicitly maps how protected attributes influence other features and outcomes. You then simulate: "What would this person's features and prediction be if their protected attribute were different?"

The Challenge

Implementing counterfactual fairness is difficult because it requires:

  • Accurate causal graphs of how attributes influence each other
  • Understanding which causal pathways are legitimate vs. discriminatory
  • Data that may not exist (you can't observe someone as both male and female)

Key Takeaway: Counterfactual fairness ensures an individual's prediction would be identical across counterfactual worlds where only their protected attributes differ, requiring explicit causal reasoning about legitimate vs. illegitimate influence pathways.