Lecture 5 · 度量公平 · Measuring Fairness

Trustworthy Machine Learning · Lecture 05。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

对应 Maps to:Stanford CS329T Spring 2022 第 4 周 “Fairness in ML”(Anupam Datta & John Mitchell,2022-04-19 的 slides:What is “fair”?、fairness metrics、COMPAS 争论、不同场景下的三种定性公平陈述、WAE vs WYSIWYG)和第 5 周的前半(2022-04-26:recap of concepts and metrics、independence / separation / sufficiency、“How do we pick a fairness metric?”)。第 4 周阅读材料:Barocas & Selbst 2016 “Big Data’s Disparate Impact”;Feldman et al. 2015 “Certifying and Removing Disparate Impact”;Dwork et al. 2012 “Fairness through Awareness”;Corbett-Davies & Goel 2018 “The Measure and Mismeasure of Fairness”。还对应 HW3 的书面题 1–5(删除受保护属性为什么不够;三个准则两两不相容的证明)和 evaluate_dem_parity / evaluate_eq_op 两个编程题,以及 Lab 4 的 fairness-metrics Colab。第 5 周后半的缓解方法(adversarial debiasing、词向量去偏、bias amplification)在第 6 讲。 配套代码 Code:code/lecture05/(numpy;5 个脚本 + 2 个模块,每个脚本 2 秒以内;导入第 1 讲的 trust_data.py 和 trust_tools.py) 预计阅读时间:3 小时(含运行代码)


0. 本讲导航 · How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. 区分”公平”的三种含义:道德上的(相似的人被相似地对待)、法律上的(disparate treatment vs disparate impact、四分之五规则)、统计上的(一个可以计算的指标),并说出它们之间的落差。
  2. Organize a dozen group-fairness metrics under independence / separation / sufficiency, and for each one say what the denominator is, whether it needs true labels, and whose errors it protects against.
  3. Prove the three pairwise impossibility results and the Kleinberg–Mullainathan–Raghavan theorem, and state exactly which assumptions they need (unequal base rates, an informative classifier, positivity).
  4. 解释 individual fairness(Dwork et al. 2012)的 Lipschitz 条件,以及为什么”相似”的度量本身就是一个价值判断。
  5. 解释 fairness through unawareness 为什么失败(代理变量、redundant encoding、Feldman 的 BER),以及标签偏差(Obermeyer et al. 2019)为什么能让指标说”公平”、系统却不公平。
  6. Summarize Corbett-Davies & Goel’s critique (threshold rules, inframarginality, the weakness of calibration), and choose, measure and document a metric for a concrete application — with sample sizes, confidence intervals and intersectional subgroups.

0.2 先修与本讲范围 Prerequisites & scope

默认你已经会 Assumed本讲省略或只预告 Omitted / previewed
第 1 讲 §5.2(Model B 的群体指标、差距的两个来源)、§7.1(三种阈值策略、Chouldechova 恒等式)、§8.1(小样本的公平差距是噪声)缓解方法:reweighing、disparate impact remover、adversarial debiasing、群体阈值后处理(第 6 讲)
条件概率、条件独立、贝叶斯公式因果公平(counterfactual fairness、path-specific effects)只做简介
逻辑回归、TPR / FPR / PPV、AUC、ECE、bootstrapNLP 与词向量中的偏见(WEAT、hard debiasing,第 6 讲);LLM 生成内容中的偏见
—排序与推荐中的公平;长期公平(feedback loops)只提一句

第 1 讲已经展示过:Model B 不看群体也有差距;完美 calibrated 的 oracle 用一个阈值也会让错误率不相等;小样本上会”测出”假差距。本讲不重复这些,而是往深处走:把指标组织成体系,证明为什么不能全要,再看测量本身在哪些地方会骗人。

0.3 本讲地图 Map

§1  "公平"是什么意思:道德、法律、定性陈述、两种世界观、伤害的类型、偏差从哪里来
§2  设定:一个分类器、两个群体、四个计数
§3  三个准则与指标动物园                                     ← 代码 01 演示 1–3
§4  不可能定理:三个两两不相容 + Kleinberg 定理(完整证明)     ← 代码 02 演示 1–3(a)
§5  个体公平:相似的人被相似地对待 ——"相似"由谁定义?          ← 代码 05 演示 1
§6  Unawareness 为什么不够:代理变量与 redundant encoding       ← 代码 03
§7  标签偏差:当"y"本身就是问题                                ← 代码 04
§8  Corbett-Davies & Goel:阈值规则、inframarginality、calibration 的弱点  ← 代码 02 演示 3(b)
§9  测量的困难:样本量、交叉群体、缺失的群体标签                  ← 代码 01 演示 4、代码 05 演示 2
§10 怎样选一个指标,怎样写下来
§11–15 小结、误区、练习、延伸阅读、下一讲预告

0.4 Notation

符号含义
A∈{0,1}A \in \{0, 1\}受保护属性(protected attribute)。本讲 group 1 是”不利群体”(unprivileged),占 30%
XX其他特征(收入、负债率、信用历史……)
Y∈{0,1}Y \in \{0, 1\}真实结果,1 = 按时还款(好结果)
RR分数(score),通常是 P^(Y=1∣⋅)\hat P(Y = 1 \mid \cdot)
Y^=1{R≥t}\hat Y = 1\{R \ge t\}决策,1 = 批准
pa=P(Y=1∣A=a)p_a = P(Y = 1 \mid A = a)群体 aa 的 base rate
U⊥V∣WU \perp V \mid W给定 WW 时 UU 与 VV 条件独立
差值 / 比值一律写成 group 1 − group 0(负数 = group 1 处于不利地位)/ group 1 ÷ group 0,和 IBM AIF360 工具包的约定相同。注意第 1 讲和第 6 讲的”TPR gap”写成 group 0 − group 1,符号和本讲相反(第 1 讲的 +0.189 就是本讲的 EOD −0.189)

0.5 关于数字 · About the numbers

讲义里的数字都来自配套代码的实际输出(固定种子,重复运行逐字相同)。数据是第 1 讲的合成信贷世界,加上本讲的 fair_data.py 新增的邮编、年龄和有偏标签。代码 01、05 里的 Model B 和第 1 讲的 Model B 逐位相同,所以它在部署数据上的群体数字(批准率 0.831 / 0.566,TPR 0.933 / 0.743……)和第 1 讲 §5.2 一致。数字只说明机制,不代表任何真实的信贷系统或真实人群。


1. “公平”是什么意思 · What does “fair” mean?

1.1 为什么这是一个难题

CS329T 的 fairness 模块以一页 “Fairness Matters” 开场:人脸识别、自然语言处理、在线广告、信贷申请、大学录取、司法判决 —— 这些系统的决定会落到具体的人身上。接着课程给出了这个话题复杂的三个原因,它们正好对应本讲的三个部分:

  1. Precise statements of compelling metrics may be mutually inconsistent. 每个指标单独看都有道理,但它们在数学上不能同时成立(§3–§4)。
  2. There may be correlations between relevant and protected characteristics. 收入、信用历史、邮编都和群体相关,所以”不看群体”挡不住群体信息(§6)。
  3. Bias in data ⇒ bias in training ⇒ bias in model. 如果训练数据本身(尤其是标签)带着历史偏见,一个”准确”的模型会准确地复现它(§6.3、§7)。

1.2 道德的定义:相似的人被相似地对待

课上的第一个定义是一条道德原则,可以追溯到亚里士多德的”同样的情况同样对待”(treat like cases alike):

If Skyler is similar to Tatum on relevant input criteria, then m(Skyler) should be similar to m(Tatum).

整句话的分量都压在 “relevant” 这个词上:什么算”相关的”标准?收入算,种族不算 —— 那么邮编呢?信用历史的长度呢(它在我们的世界里对两个群体的意义不同)?§5 会看到,Dwork et al. (2012) 把这条原则写成了精确的数学条件,而把”relevant”的定义问题原封不动地留给了一个叫 dd 的距离函数。

The second definition on the slide is legal: it is illegal to discriminate on the basis of protected characteristics — “cannot favor credit card applicants on the basis of race, gender, …”. In the US, this protection is attribute-specific and domain-specific:

DomainStatuteProtected attributes (abridged)
EmploymentTitle VII of the Civil Rights Act of 1964race, color, religion, sex, national origin
CreditEqual Credit Opportunity Act (1974) and its Regulation Brace, color, religion, national origin, sex, marital status, age (with exceptions), receipt of public assistance
HousingFair Housing Act (1968)race, color, religion, sex, national origin, familial status, disability

Two legal doctrines matter for ML:

  • Disparate treatment: treating someone differently because of a protected attribute — explicitly (“approve men above score 600 and women above 650”) or intentionally (including deliberately using a proxy as a stand-in). This is what “fairness through unawareness” tries to avoid.
  • Disparate impact: a facially neutral practice that falls disproportionately on a protected group. The landmark case is Griggs v. Duke Power Co. (1971): a high-school-diploma requirement and aptitude tests excluded Black applicants at much higher rates and had not been shown to predict job performance. Congress codified the doctrine in the Civil Rights Act of 1991. In employment it works as a burden-shifting process: (1) the plaintiff shows a statistical disparity; (2) the employer must show the practice is job-related and consistent with business necessity; (3) the plaintiff can still prevail by showing a less discriminatory alternative that serves the same purpose.

How large must a disparity be? Federal enforcement agencies use the four-fifths (80%) rule from the 1978 Uniform Guidelines on Employee Selection Procedures: a selection rate for a group that is less than 4/5 of the rate for the group with the highest rate “will generally be regarded” as evidence of adverse impact. It is a rule of thumb for deciding whether to look further, not a legal definition of discrimination; courts also look at statistical significance. Feldman et al. (2015) generalized it into the ratio DIR=P(Y^=1∣A=1)/P(Y^=1∣A=0)≤τ=0.8\text{DIR} = P(\hat Y = 1 \mid A = 1)/P(\hat Y = 1 \mid A = 0) \le \tau = 0.8.

For credit, Regulation B’s official interpretation says the “effects test” (disparate impact) may apply under ECOA, and the Supreme Court recognized disparate-impact claims under the Fair Housing Act in Texas Dept. of Housing v. Inclusive Communities Project (2015). The two doctrines can pull in opposite directions: in Ricci v. DeStefano (2009) a city threw out promotion-exam results because of their disparate impact, and the Court held that doing so was itself disparate treatment absent a “strong basis in evidence”. Any mitigation that uses the protected attribute (L6) lives inside this tension.

Barocas & Selbst’s (2016) central legal point follows from this structure. Data mining usually produces disparate impact without anyone intending it, and a model that accurately predicts the target is easy to defend as “job-related” — so disparate-impact doctrine, built for tests and diplomas, may not reach the most important sources of algorithmic discrimination (§1.7). Other jurisdictions draw similar lines (the EU distinguishes direct and indirect discrimination), and data-protection law often restricts collecting the very attributes needed to measure disparities (§9.3). None of this is legal advice; the point is that the statistical definitions in §3 are attempts to operationalize these legal and moral ideas, and each captures only part of them.

1.4 三种定性的公平陈述

课程 slides 用三句”定性的公平陈述”连接道德、法律和指标,按严格程度排列:

陈述内容严格程度对应的指标(§3)
Procedural fairness / disparate treatment决策过程不使用受保护属性,也不用其他特征作为代理去学习和使用群体身份不太严格fairness through unawareness(§6)
Equality of opportunity模型不应该给某个群体不公平的优势或劣势稍严格错误率相等:equal opportunity、equalized odds
Demographic parity(minimized inequality of outcome)在达到模型目标的前提下,资源和机会的分配尽量接近人群的群体构成相当严格批准率相等:SPD、DIR

同一个场景,三种陈述会提出完全不同的要求。Slides 里 Apple Card 信用卡额度的例子(2019 年网上广泛流传的投诉;纽约州金融服务局调查后,在 2021 年的报告里表示没有发现违反公平借贷法的证据):

  • Procedural:“如果性别和身高这样的强相关特征不是模型的输入,就没有 disparate treatment,过程是公平的。”
  • Equality of opportunity:“让不同性别的 false negative rate 相等,使’本该获批却被拒’的机会在各群体之间大致相同。”
  • Demographic parity:“申请人男女大约各半,所以男性和女性的获批率应该大致相等。”

注意 slides 的 COMPAS 版本里,“equality of opportunity”指的是让 FPR(没有再犯却被判高风险)相等;而在 Hardt et al. (2016) 的术语里,equal opportunity 专指 TPR 相等(好结果的一方)。名字相同、所指不同 —— 读论文时要看公式,不要看名字。

1.5 两种世界观:WAE vs WYSIWYG

为什么三种陈述会冲突?课程用 Friedler, Scheidegger & Venkatasubramanian (2016) 的两种世界观来解释。他们区分了构念空间(construct space:我们真正关心的东西,比如”能力”、“信用”)和观测空间(observed space:我们能测量的东西,比如 SAT 分数、信用历史长度):

WYSIWYG(What you see is what you get)WAE(We’re all equal)
假设观测到的特征和结果如实反映了能力 / 价值各群体的能力分布本来相同;观测上的差异来自结构性偏差
SAT 的例子“SAT 分数和未来的成功相关,可以作为能力的可靠指标”“SAT 编码了结构性偏差,它的分布不同不应被误认为能力的分布不同”
推论越接近真实模型 y^=y\hat y = y,越公平;需要一个无偏的结果测量完美的模型 y^=y\hat y = y 也可能不公平;不需要准确的”真实标签”
自然的指标基于准确率的指标:各群体的错误率、calibrationdemographic parity(DIR、SPD)

Slides 把 equalized odds / equal opportunity 放在两者之间:它们以观测的 yy 为准(WYSIWYG 的成分),但要求错误在群体之间均匀分布(“被公平地 / 不公平地优待的人的比例相等”)。这张表是本讲的一条暗线:§5 的”相似度度量”、§7 的标签偏差、§10 的”怎么选”,最后都会回到”你相信哪种世界观”这个问题上。

1.6 伤害的类型 · Allocation vs representation

In her NeurIPS 2017 keynote “The Trouble with Bias”, Kate Crawford distinguished two kinds of harm:

  • Allocative harm: a system withholds an opportunity or resource (a loan, a job, medical care, bail) from some groups. It can be measured by “who got what” — almost every metric in this lecture is built for it.
  • Representational harm: a system reinforces stereotypes about a group, demeans it, or erases it (search results, image captions, word embeddings that complete “man : programmer :: woman : homemaker”). No allocation need be involved, so confusion-matrix metrics can’t see it. Word-embedding bias (L6) and bias in LLM generations are of this kind.

1.7 偏差从哪里来 · Barocas & Selbst’s mechanisms

“Big Data’s Disparate Impact”(Barocas & Selbst 2016)列出了数据挖掘产生歧视的几种机制。它们是本讲后半部分的提纲:

机制含义信贷里的例子本讲
Defining the target variable“好客户”、“好员工”怎么定义,本身就是选择用”不逾期”还是”按时还清”?用”医疗花费”代替”医疗需求”(Obermeyer)§7
Training data: labeling examples标签来自过去有偏的人类判断用”信贷员当年批不批”当标签§6.3
Training data: data collection某些群体被少采样、多采样或测量得更粗糙信用档案薄(thin file)、只观察到获批者的结果§4.7、§7.5
Feature selection选择的特征对不同群体的信息量不同信用历史长度对 group 1 几乎不代表风险第 1 讲 §5.2
Proxies和受保护属性相关的特征邮编(redlining)§6
Masking故意利用以上机制来掩盖有意的歧视选一个”看似中立”的代理§6.5

2. 设定:一个分类器、两个群体、四个计数

第 1 讲已经定义了 TPR、FPR、PPV。这里只强调一件事:所有的”率”都来自同样的四个计数(TP、FP、FN、TN),区别只在分母,而”选哪个分母”就是”站在谁的角度看”:

率公式分母是谁回答的问题
selection rate(TP+FP)/n(\text{TP} + \text{FP})/n所有申请人这个群体有多少人得到了好结果?
TPR = 1 − FNRTP/(TP+FN)\text{TP}/(\text{TP} + \text{FN})真正会还款的人合格的人里,多少被批准了?(被冤枉的是 FNR)
FPRFP/(FP+TN)\text{FP}/(\text{FP} + \text{TN})真正会违约的人不合格的人里,多少被批准了?
PPVTP/(TP+FP)\text{TP}/(\text{TP} + \text{FP})被批准的人获批的人里,多少真的合格?
NPVTN/(TN+FN)\text{TN}/(\text{TN} + \text{FN})被拒绝的人被拒的人里,多少真的不合格?

申请人关心的是”像我这样合格的人,有多大机会被批”(TPR);银行关心的是”我批的人里多少会还钱”(PPV);社会关心的可能是”这个群体总共得到了多少贷款”(selection rate)。一个人的 FN 是另一个人眼里”谨慎的风控”。代码见 fairness_tools.confusion_rates。


3. 三个准则与指标动物园 · Independence, separation, sufficiency

3.1 Three criteria

Barocas, Hardt & Narayanan (Fairness and Machine Learning, ch. 3) observed that almost every group-fairness metric is a special case of one of three conditional-independence statements about the joint distribution of (A,R,Y)(A, R, Y):

CriterionFormalIn wordsBinary-decision metricsNeeds YY?Whose view
IndependenceR⊥AR \perp Athe score (or decision) carries no information about the groupequal selection rates: demographic / statistical parity, disparate impactnosociety / the group as a whole
SeparationR⊥A∣YR \perp A \mid Yamong people with the same true outcome, the score doesn’t depend on the groupequal TPR (equal opportunity), equal TPR and FPR (equalized odds)yesthe applicant who is (un)qualified
SufficiencyY⊥A∣RY \perp A \mid Ronce you know the score, the group tells you nothing more about the outcomeequal PPV (predictive parity) and NPV; for scores, calibration within groupsyesthe decision maker who acts on the score

The slides phrase the same three conditions as: predictions independent of class membership; predictions independent of class membership given the true outcome (“performance is the same across classes”); true outcomes independent of class membership given the predictions (“no extra information encoded in the protected class”). And they state the punchline we prove in §4: no two can be simultaneously enforced in non-degenerate cases.

Why these three, intuitively?

  • Independence is about outcomes: does the group get its share?
  • Separation is about errors: given that you would repay, is your chance of being wrongly denied the same as anyone else’s?
  • Sufficiency is about meaning: does a score of 0.7 mean the same thing for everyone?

3.2 指标动物园 · The metrics zoo

工业界的工具包(IBM AIF360、Aequitas、Fairlearn)和课程 Lab 4 的 Colab 用的是下面这些名字。代码在 fairness_tools.fairness_metrics:

准则指标定义(group 1 − group 0 或 ÷)理想值
independencestatistical parity difference (SPD)sel1−sel0\text{sel}_1 - \text{sel}_00
independencedisparate impact ratio (DIR)sel1/sel0\text{sel}_1 / \text{sel}_0;四分之五规则要求 ≥ 0.81
separationequal opportunity difference (EOD)TPR1−TPR0\text{TPR}_1 - \text{TPR}_00
separationFPR differenceFPR1−FPR0\text{FPR}_1 - \text{FPR}_00
separationaverage odds difference (AOD)12[(FPR1−FPR0)+(TPR1−TPR0)]\tfrac12[(\text{FPR}_1 - \text{FPR}_0) + (\text{TPR}_1 - \text{TPR}_0)]0
separationequalized odds violationmax⁡(∣ΔTPR∣,∣ΔFPR∣)\max(\lvert\Delta\text{TPR}\rvert, \lvert\Delta\text{FPR}\rvert)0
sufficiencypredictive parity differencePPV1−PPV0\text{PPV}_1 - \text{PPV}_00
sufficiencyNPV differenceNPV1−NPV0\text{NPV}_1 - \text{NPV}_00
sufficiencycalibration gap同一分数区间里两个群体实际正例比例之差,按人数加权平均0
otheraccuracy differenceacc1−acc0\text{acc}_1 - \text{acc}_00
othertreatment equality(Berk et al. 2018)(FN/FP)1 / (FN/FP)0(\text{FN}/\text{FP})_1 \,/\, (\text{FN}/\text{FP})_01

两个小提醒。AOD 是一个平均值,两项方向相反时会互相抵消(TPR 差 +0.1、FPR 差 −0.1 的模型 AOD = 0),所以要同时看 equalized odds violation。HW3 的 evaluate_dem_parity 和 evaluate_eq_op 就是这张表的前两类:返回两个群体各自的 P(Y^=1∣A=a)P(\hat Y = 1 \mid A = a) 和 P(Y^=1∣Y=1,A=a)P(\hat Y = 1 \mid Y = 1, A = a)。

3.3 一次算完:Model B 的指标动物园

代码 01 演示 1:第 1 讲的 Model B(不看群体的逻辑回归,阈值 0.5),在第 1 讲的部署数据上(4000 人),95% bootstrap 置信区间:

准则指标值 [95% CI]CI 不含理想值?
independenceSPD−0.265 [−0.294, −0.235]是
independenceDIR0.681 [0.648, 0.716]是(< 0.8)
separationEOD−0.189 [−0.225, −0.153]是
separationFPR_diff−0.267 [−0.316, −0.208]是
separationAOD−0.228 [−0.259, −0.197]是
sufficiencyPPV_diff−0.027 [−0.063, 0.006]否
sufficiencyNPV_diff−0.064 [−0.122, −0.002]是
sufficiencycal_gap0.061 [0.045, 0.094]是
otheracc_diff−0.066 [−0.097, −0.036]是
otherTE_ratio4.071 [3.048, 5.469]是

同一个模型、同一份数据,三个准则讲了三个不同的故事:

  • Independence 说:group 1 的批准率低 0.265,DIR 0.681,按四分之五规则会被视为 adverse impact 的证据。
  • Separation 说:B 对 group 1 整体”更严” —— 会还款的人被批准的比例低 0.189,会违约的人被批准的比例也低 0.267。
  • Sufficiency 说:被批准的人里,两个群体真的还款的比例几乎一样(PPV 差 −0.027,不显著)。如果你是一个只看”我批的人表现如何”的银行,你会觉得没问题。

还有两个数字值得停一下。NPV:被拒绝的 group 1 申请人里有 35% 其实会还款(group 0 是 29%)。TE_ratio ≈ 4.1:两个群体的准确率只差 0.066,但错误的种类完全不同 —— group 0 的错误主要是”批了不该批的”(对银行不利),group 1 的错误主要是”拒了不该拒的”(对申请人不利)。只看准确率差距,会完全错过这一点。

3.4 比值还是差值?四分之五规则的一个陷阱

代码 01 演示 2。四分之五规则用的是批准率之比。如果把”被拒绝”当成要比较的结果呢?

Model B值four-fifths?
批准率之比 sel1/sel0\text{sel}_1/\text{sel}_0(EEOC 的用法)0.681fails
拒绝率之比 rej0/rej1\text{rej}_0/\text{rej}_10.389fails
批准率之差 / 拒绝率之差−0.265 / +0.265—

更极端的是:四种情形的差距都是 0.10,两种比值给它们排出的顺序正好相反:

sel₀sel₁SPD批准率之比拒绝率之比
0.950.85−0.100.8950.333
0.600.50−0.100.8330.800
0.300.20−0.100.6670.875
0.150.05−0.100.3330.895

Ratios are sensitive to whichever outcome is rare; differences are not. Neither is wrong — a ratio asks about relative chances, a difference about how many people are affected — but a report that quotes a ratio must say which outcome counts as favorable, and should usually give the difference too.

3.5 指标属于(模型, 阈值, 人群),不只属于模型

代码 01 演示 3,同一个 Model B,只改阈值:

阈值approve g0approve g1DIRSPDEODFPR_diffPPV_diffaccuracy
0.30.9410.7920.842−0.148−0.058−0.233−0.0570.740
0.40.8920.6790.761−0.213−0.121−0.270−0.0390.758
0.50.8310.5660.681−0.265−0.189−0.267−0.0270.768
0.60.7570.4430.586−0.314−0.261−0.262−0.0090.754
0.70.6390.3100.485−0.329−0.328−0.185−0.0150.717

阈值 0.3 时 DIR 通过四分之五规则,0.7 时只有 0.485。收紧阈值让 independence 和 equal opportunity 变差,却让 predictive parity 变好;FPR 差距在 0.4 附近最大。准确率在 0.4–0.6 之间几乎不变,公平指标却变化很大 —— 和第 1 讲 §7.1 一样,“选阈值”在准确率上几乎免费,在公平上一点也不免费。所以一个公平数字必须带着它的阈值和人群一起报告。

3.6 分数层面 vs 决策层面

Sufficiency 有两个版本,容易混淆:

  • 分数层面:calibration within groups,P(Y=1∣R=r,A=a)=rP(Y = 1 \mid R = r, A = a) = r 对两个群体都成立。
  • 决策层面:predictive parity,P(Y=1∣Y^=1,A=a)P(Y = 1 \mid \hat Y = 1, A = a) 相等。

前者不蕴含后者。第 1 讲 §7.1 的 oracle 在两个群体内都完美 calibrated,用同一个阈值 0.5,PPV 却是 0.814 vs 0.757:PPV 是 calibrated 分数在”阈值以上”那一段的平均,而两个群体在阈值以上的分数分布不同。Separation 也一样:决策层面只要求某一个阈值下 TPR、FPR 相等,分数层面要求所有阈值下都相等。§4 用分数层面的版本,因为定理在那里最干净。


4. 不可能定理 · Impossibility results

4.1 Statement

Let YY be binary, and suppose base rates differ: p0≠p1p_0 \ne p_1, i.e. A⊥̸YA \not\perp Y. Then:

  1. Independence and sufficiency cannot both hold (for any RR).
  2. Independence and separation cannot both hold, unless R⊥YR \perp Y (the score is useless).
  3. Separation and sufficiency cannot both hold, under a positivity condition (every combination of AA, RR, YY has positive probability) — for binary decisions, unless the classifier is perfect or degenerate.

So in any non-degenerate situation, at most one of the three criteria can hold. These are HW3’s written exercises 3–5. The proofs are short, and each one shows why the conflict exists.

4.2 Independence vs sufficiency

Assume R⊥AR \perp A (independence) and Y⊥A∣RY \perp A \mid R (sufficiency). For any aa and yy, by the law of total probability:

P(Y=y∣A=a)=∑rP(Y=y∣R=r,A=a) P(R=r∣A=a)=∑rP(Y=y∣R=r) P(R=r)=P(Y=y).P(Y = y \mid A = a) = \sum_r P(Y = y \mid R = r, A = a)\, P(R = r \mid A = a) = \sum_r P(Y = y \mid R = r)\, P(R = r) = P(Y = y).

The first replacement uses sufficiency, the second independence. So A⊥YA \perp Y: base rates are equal. Contrapositive: if base rates differ, the two criteria can’t both hold. No assumption about RR is needed at all.

直觉:sufficiency 说”分数说明一切”,independence 说”两个群体的分数分布一样”;如果两者都成立,两个群体的结果分布也就一样了 —— 和”base rate 不同”矛盾。

4.3 Independence vs separation

Assume R⊥A∣YR \perp A \mid Y (separation) and write qy(r)=P(R=r∣Y=y)q_y(r) = P(R = r \mid Y = y), which by separation doesn’t depend on aa. Then

P(R=r∣A=a)=pa q1(r)+(1−pa) q0(r).P(R = r \mid A = a) = p_a\, q_1(r) + (1 - p_a)\, q_0(r).

Independence requires this to be the same for a=0a = 0 and a=1a = 1:

(p0−p1) (q1(r)−q0(r))=0for every r.(p_0 - p_1)\,\big(q_1(r) - q_0(r)\big) = 0 \quad \text{for every } r.

If p0≠p1p_0 \ne p_1, then q1(r)=q0(r)q_1(r) = q_0(r) for all rr: the score has the same distribution for people who repay and people who default, i.e. R⊥YR \perp Y — it is useless. 直觉:如果分数在”好人”和”坏人”里各自对两个群体一视同仁(separation),那么好人比例更高的群体自然得到更高的分(independence 被违反)—— 除非分数根本不区分好人坏人。

4.4 Separation vs sufficiency

For a binary decision this follows from Chouldechova’s identity, which L1 §7.1 verified numerically:

FPRa=pa1−pa⋅1−PPVaPPVa⋅TPRa.\text{FPR}_a = \frac{p_a}{1 - p_a}\cdot\frac{1 - \text{PPV}_a}{\text{PPV}_a}\cdot\text{TPR}_a .

Separation makes TPR\text{TPR} and FPR\text{FPR} equal across groups; sufficiency makes PPV\text{PPV} equal. If TPR>0\text{TPR} > 0 and 0<PPV<10 < \text{PPV} < 1, dividing the identity for the two groups leaves p0/(1−p0)=p1/(1−p1)p_0/(1 - p_0) = p_1/(1 - p_1), i.e. p0=p1p_0 = p_1. The escape hatches are degenerate: PPV=1\text{PPV} = 1 and FPR=0\text{FPR} = 0 (no false positives at all), or TPR=0\text{TPR} = 0 (nobody approved). This argument used only PPV; full sufficiency also requires equal NPV, and the mirror-image identity FNRa=1−papa⋅1−NPVaNPVa⋅TNRa\text{FNR}_a = \frac{1 - p_a}{p_a}\cdot\frac{1 - \text{NPV}_a}{\text{NPV}_a}\cdot\text{TNR}_a closes the first hatch unless the classifier also makes no false negatives — i.e. is perfect.

For general scores, use a property of conditional independence (the hint in HW3 Q5): if the joint distribution is strictly positive, then U⊥V∣WU \perp V \mid W and U⊥W∣VU \perp W \mid V together imply U⊥(V,W)U \perp (V, W). With U=AU = A, V=RV = R, W=YW = Y: separation (A⊥R∣YA \perp R \mid Y) plus sufficiency (A⊥Y∣RA \perp Y \mid R) imply A⊥(R,Y)A \perp (R, Y), hence A⊥YA \perp Y. The positivity assumption is what rules out the degenerate cases.

4.5 Kleinberg, Mullainathan & Raghavan (2016)

The COMPAS debate (L1 §3.2) was about scores, not just decisions: ProPublica pointed at error rates, Northpointe at calibration. Kleinberg et al. formalized three properties of a risk score:

  • (A) Calibration within groups: among people in group aa with score ss, a fraction ss are positive.
  • (B) Balance for the negative class: xa=E[R∣Y=0,A=a]x_a = \mathbb{E}[R \mid Y = 0, A = a] is the same for both groups (“a generalized FPR”).
  • (C) Balance for the positive class: ta=E[R∣Y=1,A=a]t_a = \mathbb{E}[R \mid Y = 1, A = a] is the same (“a generalized TPR”).

Theorem. (A), (B) and (C) can all hold only if base rates are equal or prediction is perfect.

Proof. Calibration within group aa implies that the scores add up to the number of positives: ∑i∈asi=∑i∈ayi\sum_{i \in a} s_i = \sum_{i \in a} y_i (in expectation; exactly, if the score is calibrated in the sample). Split the left-hand sum by the true label and divide by the group size nan_a:

(1−pa) xa+pa ta=pa⟺(1−pa) xa=pa (1−ta).(1 - p_a)\,x_a + p_a\,t_a = p_a \quad\Longleftrightarrow\quad (1 - p_a)\,x_a = p_a\,(1 - t_a).

So each group’s point (xa,ta)(x_a, t_a) lies on the line x=ka(1−t)x = k_a(1 - t) with slope ka=pa/(1−pa)k_a = p_a/(1 - p_a), the odds of the base rate. Balance (B) and (C) say both groups sit at the same point (x,t)(x, t). That point would have to lie on both lines; if p0≠p1p_0 \ne p_1 the slopes differ, and two lines through (0,1)(0, 1) with different slopes meet only there: x=0x = 0, t=1t = 1 — every defaulter gets score 0 and every repayer score 1. ∎

代码 02 演示 2 在第 1 讲的信贷世界里检验这条”KMR 直线”(5 万人,分数 = 真实还款概率):

分数群体ppxxtt(1−p) x(1-p)\,xp (1−t)p\,(1-t)斜率 p/(1−p)p/(1-p)
oracle ptruep_\text{true}00.7070.5050.7970.148150.143642.408
oracle ptruep_\text{true}10.5780.4320.6950.182520.176401.368
样本内重新校准00.7070.5010.7920.147070.147072.408
样本内重新校准10.5780.4270.6880.180520.180521.368

oracle 只在期望意义下 calibrated,两边在第三位小数上有差别(差值正好等于”本群体平均分数 − 实际还款率”,是抽样噪声);把分数在样本内重新校准后,两边逐位相等 —— 恒等式是一个计数事实,和 Chouldechova 恒等式同一个道理。oracle 的 balance 差距:会违约的 group 0 申请人平均得分比 group 1 高 0.073,会还款的高 0.102。这不是模型的错(oracle 没有错),而是 calibration 在 base rate 不同时的必然代价。

4.6 扫描 base rate:差距从 0 开始

代码 02 演示 1 用一个只有一个特征的极简世界(make_latent_world):y∼Bernoulli(pa)y \sim \text{Bernoulli}(p_a),x∣y∼N(±0.75,1)x \mid y \sim \mathcal{N}(\pm 0.75, 1),两个群体的 xx 对 yy 的信息量完全相同(AUC ≈ 0.86),唯一的差别是 base rate。构造三种分数,各自”天生”满足一个准则:

  • blind =σ(1.5 x)= \sigma(1.5\,x):只看 xx 的似然比。P(R∣Y,A)P(R \mid Y, A) 与群体无关 ⇒ separation 精确成立。
  • calibrated =σ(1.5 x+logit pa)= \sigma(1.5\,x + \text{logit}\,p_a):贝叶斯后验,用了群体的 base rate ⇒ sufficiency 精确成立。
  • within-group rank:blind 分数在本群体内的百分位 ⇒ 两组分数都是均匀分布 ⇒ independence 精确成立。

每个准则的违反程度都在所有阈值上量:independence 用”任意阈值下批准率差距的最大值”(两组分数分布的 KS 距离),separation 用”任意阈值下 TPR / FPR 差距的最大值”,sufficiency 用两条校准曲线的平均距离。每组 5 万人,”✓“表示违反程度 < 0.02:

p0p_0p1p_1分数independenceseparationsufficiency成立
0.60.6blind0.0120.0130.009✓✓✓
0.60.6calibrated0.0120.0130.006✓✓✓
0.60.6within-group rank0.0000.0050.007✓✓✓
0.60.5blind0.0550.0070.059✗✓✗
0.60.5calibrated0.1370.1130.005✗✗✓
0.60.5within-group rank0.0000.0660.096✓✗✗
0.60.4blind0.1110.0080.127✗✓✗
0.60.4calibrated0.2680.2160.009✗✗✓
0.60.4within-group rank0.0000.1360.202✓✗✗
0.60.3blind0.1650.0090.194✗✓✗
0.60.3calibrated0.4040.3260.009✗✗✓
0.60.3within-group rank0.0000.2080.303✓✗✗
  • Base rate 相等时,三个分数对三个准则的违反都不超过 0.013(只剩抽样噪声 —— 这一组也是”噪声地板”,0.02 的容差就是按它定的)。三个准则同时成立。
  • Base rate 一旦不同,每个分数恰好满足它被构造来满足的那一个,另外两个都被违反;没有任何一行出现两个 ✓。这就是 §4.2–§4.4 的数值版本。
  • 违反程度大致和 base rate 差距成正比(calibrated 分数的 separation 违反:0.113 / 0.216 / 0.326)。所以在讨论任何公平指标之前,先报告 base rate 差多少。
  • 注意 blind 分数并不”中立”:同一个 xx 给两个群体同样的分数,于是在 base rate 低的群体里它系统性地偏高(sufficiency 被违反)。“对每个人用同一个公式”满足的是 separation,不是 calibration。

4.7 定理没有说的事 · What the theorems don’t say

(a) Equal base rates are necessary, not sufficient. 代码 02 演示 3(a):两个群体的 base rate 都是 0.5,但 group 1 的特征更”粗糙”(两类均值差 0.75,group 0 是 1.5)。各群体的 calibrated 分数:

分数independenceseparationsufficiencyAUC g0AUC g1成立
calibrated(各群体的后验)0.2030.3680.0150.8530.700✗✗✓
leveled down(给 group 0 的特征加噪声)0.0090.0110.0050.6990.700✓✓✓

Base rate 相同,calibrated 分数仍然违反 separation:group 1 的分数挤在 0.5 附近,会还款的 group 1 申请人得不到高分。不可能定理的逆命题不成立 —— 相等的 base rate 只是让”全满足”变得可能。怎么才能全满足?上表第二行把 group 0 的信息也降到和 group 1 一样差(“leveling down”):三个准则都 ✓,group 0 的 AUC 从 0.853 掉到 0.699,group 1 一点也没有变好。数学上”公平”,伦理上很难辩护。真正的修复是改善对 group 1 的测量,这是数据问题,不是指标问题。

(b) The theorems don’t say fairness is impossible. 它们说的是:在 base rate 不同的世界里,你必须选。Kleinberg et al. 还证明了近似版本(三个性质近似成立,要求 base rate 近似相等或预测近似完美);Pleiss et al. (2017) 证明 calibration 只能和 equalized odds 的一个”放松”版本兼容,而且实现它的方法是对一部分人随机地丢掉信息 —— 又一个 leveling down。

(c) The theorems say nothing about which criterion is right. 那是 §8 和 §10 的问题。


5. 个体公平 · Individual fairness

5.1 Dwork et al.’s Lipschitz condition

Group criteria compare averages; they say nothing about any particular person. Dwork, Hardt, Pitassi, Reingold & Zemel (2012) formalized the moral principle of §1.2 instead. Let MM map each individual xx to a distribution over outcomes, and let d(x,x′)d(x, x') be a task-specific similarity metric on individuals. MM is individually fair if it is Lipschitz:

D(M(x),M(x′))≤d(x,x′)for all x,x′,D\big(M(x), M(x')\big) \le d(x, x') \qquad \text{for all } x, x',

where DD is a distance between outcome distributions (e.g. total variation). For a score, read it as ∣f(x)−f(x′)∣≤L⋅d(x,x′)\lvert f(x) - f(x')\rvert \le L \cdot d(x, x'): people who are close under dd must get close scores. Given dd, finding the most useful fair classifier is a linear program. The paper’s title, Fairness through Awareness, is a deliberate contrast with “fairness through unawareness”: a good dd may need to know the group (e.g. to compare people across groups by their rank within their own group). The authors are explicit that the metric is the hard part — they envision it being public, open to debate, and ideally supplied by a regulator or domain experts.

Two facts relate this to §3. First, Lipschitz-ness implies statistical parity only when the two groups’ distributions are close under dd (an earthmover-type distance); when the groups really differ in dd, individual fairness permits different selection rates. Second, enforcing group parity by group-specific thresholds can violate individual fairness: two applicants with nearly identical features, one per group, get different decisions.

5.2 “相似”由谁定义?

代码 05 演示 1 用两种距离比较三种决策规则:

  • raw:Model B 自己使用的标准化特征上的欧氏距离 —— “观察到的特征就是能力”(WYSIWYG)。
  • pct:每个特征换成”在本群体内的百分位”再算距离 —— “在本群体里排名相同的人才是相似的人”(WAE 的一种表达:group 1 的信用历史短是结构性原因造成的)。

两个量:consistency(Zemel et al. 2013)=1−1n∑i∣y^i−1k∑j∈kNN(i)y^j∣= 1 - \frac1n\sum_i \big\lvert \hat y_i - \frac1k\sum_{j \in \text{kNN}(i)} \hat y_j \big\rvert,k=10k = 10;以及跨群体的”最近双胞胎”:每个 group 1 申请人在 group 0 里找距离最近的人,比较两人的分数和决策。

决策规则度量 ddconsistency双胞胎 ∣Δp∣\lvert\Delta p\rvert双胞胎 Δp\Delta p(g1 − 双胞胎)双胞胎决策不同
Model B,阈值 0.5raw0.9170.058−0.0229.1%
Model B,阈值 0.5pct0.8210.202−0.19927.6%
Model B + 按群体设阈值(DP)raw0.8630.058−0.02227.7%
Model B + 按群体设阈值(DP)pct0.8770.202−0.1999.7%
aware 模型(group、group × history)raw0.8940.116+0.08516.2%
aware 模型(group、group × history)pct0.8400.168−0.14221.2%
  • 在 raw 度量下,Model B 是表里最”个体公平”的规则(consistency 最高、双胞胎决策不一致最少),而且它的平滑性可以证明:sigmoid 的斜率不超过 1/4,再用 Cauchy–Schwarz,∣σ(z)−σ(z′)∣≤14∥θ∥2 ∥x~−x~′∥2\lvert\sigma(z) - \sigma(z')\rvert \le \tfrac14\lVert\theta\rVert_2\,\lVert\tilde x - \tilde x'\rVert_2,所以 B 是 L=∥θ∥2/4=0.392L = \lVert\theta\rVert_2/4 = 0.392 的 Lipschitz 函数(随机抽的 2 万对跨群体样本里最大比值是 0.340)。
  • 换成 pct 度量,同一个 Model B 给 group 1 申请人的分数比 TA 的双胞胎平均低 0.199,决策不一致从 9.1% 升到 27.6%。模型没变,变的只是”谁和谁相似”。
  • 按群体设阈值(DP)在 raw 度量下破坏个体公平(9.1% → 27.7%,正是 Dwork et al. 指出的现象),在 pct 度量下却修复了它(27.6% → 9.7%)。同一个干预,换一个 dd,评价完全相反。
  • aware 模型知道信用历史对 group 1 意义不同,这类模型在真实标签下最准、最 calibrated(代码 03 演示 3),但在 raw 度量下”违反”个体公平:同样短的信用历史,它给 group 1 的分更高(+0.085)。

所以个体公平不能离开 dd 讨论:选 dd 就是做价值判断,它把 WAE 和 WYSIWYG 的争论原封不动地搬进了一个距离函数。个体公平的贡献不是回避这个判断,而是把它显式化:写下 dd,别人就可以争论它。

5.3 Counterfactual fairness(简介)

另一条路线问的是因果问题:如果把这个人的群体”换掉”、而其他一切按因果结构相应变化,决策会变吗?Kusner et al. (2017) 的 counterfactual fairness 要求决策在这个反事实下不变。它需要一个因果模型(群体如何影响收入、信用历史……),而因果模型本身又是一组有争议的假设。我们的 pct 度量可以看作一个粗糙的近似:“反事实地”把 group 1 申请人放到 group 0,TA 会处在相同的百分位。


6. Unawareness 为什么不够:代理变量 · Proxies and redundant encodings

6.1 为什么大家都想”不看群体”

Fairness through unawareness(slides 的 procedural fairness)有三个吸引人的地方:简单;符合”disparate treatment 禁止使用受保护属性”的法律直觉;不需要收集敏感数据。HW3 书面题 1 的问题正是:“简单地从特征里删掉受保护属性,为什么不一定有效?” 第 1 讲 §5.2 给出了两个答案(世界的差异、模型的错设)。这一节给第三个:群体信息藏在别的特征里,而历史偏见会通过它们回到模型中。

6.2 Redundant encoding 与 Feldman 的”可认证”

Barocas & Selbst 把这叫做 redundant encoding:受保护属性被冗余地编码在其他特征里。最直接的检验是反过来问:能不能从其他特征预测出群体? 代码 03 演示 1 在我们的世界里加了一个邮编(87% 的 group 1 住在 7–9 号街区,模拟居住隔离 / redlining 的历史),训练逻辑回归去预测群体,在另一份数据上评估:

用来预测群体的特征AUCBER
5 个正当特征(Model B 的输入)0.8300.249
只有邮编0.8990.106
5 个特征 + 邮编0.9550.099
只有收入 + 信用历史0.8290.247
负债率、逾期、查询(生成时与群体无关)0.5020.500

BER(balanced error rate)=12[P(a^=0∣a=1)+P(a^=1∣a=0)]= \tfrac12[P(\hat a = 0 \mid a = 1) + P(\hat a = 1 \mid a = 0)] 是 Feldman et al. (2015) 用的量:它对两类一视同仁,“全猜 group 0”的分类器 BER = 0.5(而普通准确率会是 70%)。他们证明了一个漂亮的结论(Theorem 4.1):在四分之五规则的意义下,一份数据”允许 disparate impact”(存在一个只用这些特征的分类器,其 DIR ≤ 0.8),当且仅当群体能从这些特征以 BER ≤ 12−β/8\tfrac12 - \beta/8 被预测出来,β\beta 是少数群体被选中的比例。于是认证(certification)可以不审查模型、只审查数据:如果最好的群体预测器的 BER 都高于这个界,那么任何用这些特征的模型都不会违反四分之五规则。

对我们的数据,取 β=0.566\beta = 0.566(Model B 对 group 1 的批准率),界是 0.429。除了”与群体无关”的那一行,所有特征组合的 BER 都远低于它:这份数据无法被认证。Feldman et al. 的后半篇还给出了”修复”(repair)方法:把每个群体的特征分布按分位数对齐到一个共同的”中位数分布”,保留群体内的排序 —— 那是第 6 讲的 pre-processing。

6.3 模仿有偏的历史决定

有了代理,偏见从哪里来?Barocas & Selbst 的第二个机制:标签来自过去有偏的人类判断。代码 03 演示 2:过去的信贷员对风险判断大体正确,但对 group 1 额外减了 1 个 logit:P(批准)=σ(true logit−1.0⋅a)P(\text{批准}) = \sigma(\text{true logit} - 1.0\cdot a)。银行用他们的决定当标签,训练模型”学会像过去一样决定”。我们用一个只有合成数据才能算的量来衡量每个决策规则 —— same-risk gap:把人按真实还款概率分成 10 层,每层里比较批准率(group 1 − group 0),按 group 1 的人数加权平均。它回答:“一个 group 1 申请人,比一个和 TA 风险相同的 group 0 申请人,被批准的概率低多少?”

决策approve g0approve g1SPDsame-risk gapacc(真实 y)
oracle:真实 p≥0.5p \ge 0.5(参照)0.7940.651−0.144−0.0020.774
历史信贷员(有偏)0.7250.426−0.299−0.1800.690
模仿信贷员 · aware(5 + group)0.8090.342−0.467−0.3340.744
模仿信贷员 · unaware(5)0.7650.444−0.321−0.1620.755
模仿信贷员 · unaware + 邮编0.7940.379−0.415−0.2740.747
模仿信贷员 · 只用与群体无关的 3 个特征0.7640.773+0.009+0.1140.710
  • oracle 的 SPD 是 −0.144,但 same-risk gap 几乎为 0:它的批准率差距完全来自风险分布的不同。按”风险相同则对待相同”的标准,这不算歧视(WAE 的观点会不同意 —— 它会问风险分布为什么不同)。
  • 信贷员对同等风险的 group 1 申请人,批准率低 0.180 —— 这就是那 1 个 logit。
  • aware 模型把偏见放大了:−0.334,几乎是信贷员的两倍。这是我们没有预料到的结果,原因是阈值化:信贷员的决定有随机性(P(批准)=0.45P(\text{批准}) = 0.45 的人有时也会被批),模型却把 P≥0.5P \ge 0.5 一律批、P<0.5P < 0.5 一律拒,同一个偏见被一致地、毫无例外地执行了。这是 bias amplification 最简单的形式(第 6 讲会看到 Zhao et al. 2017 在图像标注里观察到的同类现象:训练数据里 66% 的”做饭”图片有女性,模型的预测里变成了 84%)。
  • unaware 模型仍然复现了 aware 模型 48% 的折扣:它用收入和信用历史”猜”群体,再把折扣加在猜出来的人身上;加上邮编后复现了 82%。去掉群体标签,只是让模型换一条路学同一个偏见,代理越好学得越像。
  • 只用与群体无关的 3 个特征:批准率几乎相等(SPD +0.009,independence 近似成立),但 same-risk gap 变成 +0.114 —— 在同样的真实风险下,group 1 反而更容易被批准(同样风险的 group 1 申请人收入和历史较弱,必须在负债、逾期上更好,而模型只看得到后者)。准确率也从 0.755 掉到 0.710。把所有相关特征都删掉,换来的是另一个方向的不一致和一个更差的模型。

6.4 同一个代理,标签真实时作用相反

代码 03 演示 3:这次用真实还款结果训练:

模型(真实标签)approve g1SPDsame-risk gapgroup 1 平均预测 / 实际acc
unaware(和 Model B 同样的设定)0.596−0.240−0.1250.563 / 0.6130.766
unaware + 邮编0.634−0.190−0.0670.583 / 0.6130.767
aware(group、group × history)0.660−0.145−0.0090.597 / 0.6130.769

标签真实时,unaware 模型的负 same-risk gap 来自第 1 讲的 thin-file 错设(它低估 group 1)。加上邮编,模型能部分地”认出” group 1,从而部分地纠正对 group 1 信用历史的过度惩罚:gap 从 −0.125 缩小到 −0.067。和 §6.3 放在一起看:同一个代理变量,标签有偏时把偏见带进模型(−0.162 → −0.274),标签真实时帮模型纠正错设(−0.125 → −0.067)。代理变量本身无所谓好坏,它只是把”标签里和群体有关的信息”传给模型。

6.5 教训:treatment 与 impact 之间的张力

  • Removing the attribute doesn’t remove the information (Feldman’s BER), and removing all correlated features removes the signal too (“proxy whack-a-mole”).
  • 审计的重点应该是标签和结果,而不是机械地删特征(§7)。这也是 Corbett-Davies & Goel 批评 anti-classification 的理由(§8.4)。Kleinberg, Ludwig, Mullainathan & Rambachan (2018) 在一个大学录取的例子里说明:允许模型使用群体,可以同时提高效率和公平。
  • 但法律通常禁止直接使用受保护属性,哪怕是为了纠正错设。Lipton, McAuley & Chouldechova (2018) 把这个问题问得很尖锐:“要缓解 impact disparity,是否需要 treatment disparity?” 他们的答案是:不使用群体的”间接”方法会通过代理隐式地使用它,而且往往做得更差。
  • 另一个方向:有些和群体相关的特征是业务上必需的(business necessity)。课程 slides 引用的 Dutta, Venkatesh, Mardziel, Datta & Grover (2020) 研究了如何把差距拆成”可以由被豁免的关键特征解释的部分”和”不能解释的部分”,只把后者算作需要纠正的偏差。

7. 标签偏差:当”y”本身就是问题 · Label bias

7.1 Obermeyer et al. (2019)

US health systems widely use algorithms to flag “high-risk” patients for extra-care programs. The algorithm studied by Obermeyer, Powers, Vogeli & Mullainathan is typical of this industry-wide approach and affects millions of patients; it predicts future health-care cost and uses cost as a proxy for health need. It is calibrated for cost: at a given risk score, Black and white patients go on to generate similar costs. But at a given risk score, Black patients have substantially more chronic illnesses — because, at the same level of need, less money is spent on Black patients (differences in access, trust and treatment). The authors estimate that removing this bias would raise the share of Black patients among those automatically enrolled from 17.7% to 46.5%. Working with the vendor, they replaced the label with an index that also includes health measures, and the bias dropped sharply. The problem was the label, and so was the fix.

7.2 构念与测量 · Construct vs measurement

Jacobs & Wallach (2021) frame this as a measurement problem: the thing we care about (“creditworthiness”, “health need”, “risk of reoffending”) is an unobservable construct; the label we train on (“repaid as recorded”, “cost”, “re-arrested”) is a measurement of it, with its own errors — and those errors can differ by group. This is exactly Friedler et al.’s gap between construct space and observed space (§1.5). Every metric in §3 except independence uses YY, so a label-dependent fairness metric is at most as fair as the label.

7.3 一个审计员看不到的偏差

代码 04 在信贷世界里重现 Obermeyer 的结构:数据库里记录的还款结果对 group 1 打了折扣,P(yobs=1∣x,a)=σ(true logit−1.0⋅a)P(y_\text{obs} = 1 \mid x, a) = \sigma(\text{true logit} - 1.0\cdot a)(越接近决策边界的 group 1 好人越容易被记成违约)。group 1 的真实还款率 0.572,记录的只有 0.388。为了让”标签偏差”成为唯一的问题,我们给模型最好的条件:函数形式和真实世界一致(log income、group、group × history),它会精确地学会它的标签。

模型用什么标签审计sel g0sel g1TPR g0TPR g1PPV g0PPV g1cal_gapg1 平均预测 − base rate
用 yobsy_\text{obs} 训练yobsy_\text{obs}0.8020.3740.9180.6360.8140.6580.044+0.034
用 yobsy_\text{obs} 训练真实 yy0.8020.3740.9180.5420.8140.8280.124−0.150
用真实 yy 训练yobsy_\text{obs}0.8010.6690.9170.8930.8130.5180.201+0.214
用真实 yy 训练真实 yy0.8010.6690.9170.8430.8130.7210.035+0.030
  • 第一行是审计员能看到的全部:cal_gap 0.044,和第四行(好模型、真实标签)是同一个量级。按 sufficiency,这个模型”公平”。(两行的 +0.03 来自评估样本:group 1 的还款率碰巧比训练样本低 0.020。)
  • 第二行,同一个模型、同样的决策,换成真实标签审计:group 1 被低估 0.150,TPR 差距从 0.282 扩大到 0.376。这件事在第一行里看不出来。
  • 第三行最值得警惕:用真实标签训练的好模型,在只有 yobsy_\text{obs} 的审计员眼里偏袒 group 1(平均预测比”记录的还款率”高 0.214,PPV₁ 只有 0.518)。审计员会要求”修正”它 —— 修正的方向正好是把好模型改回有偏的模型。
  • 批准率(sel)在同一个模型的两行里完全一样:independence 不依赖标签,所以不受标签偏差影响 —— 这是它少有的优点,也是 WAE 立场偏爱它的原因之一。

同一个分数上,真实情况是什么样?代码 04 演示 2 把 yobsy_\text{obs} 模型的分数分成 10 个区间(摘录):

分数区间yobsy_\text{obs} g0yobsy_\text{obs} g1真实 yy g0真实 yy g1真实差距
[0.1, 0.2)0.1080.1370.1080.305+0.198
[0.3, 0.4)0.3380.3210.3380.570+0.232
[0.5, 0.6)0.5570.4920.5570.712+0.155
[0.7, 0.8)0.7730.6640.7730.855+0.082
[0.9, 1.0)0.9430.9630.9430.981+0.038

按记录的标签,两条校准曲线大致重合;按真实标签,每个分数区间里 group 1 的真实还款率都更高(全部 10 个区间都是正数,0.1–0.7 之间差 0.155–0.232)。这正是 Obermeyer 论文核心图表的形状。这张表只有在拿到独立于训练标签的测量时才能画出来 —— Obermeyer 等人用的是病历里的慢性病数量。

最后,资源有限时(只批准分数最高的 50%),换掉标签就改变了谁得到资源(代码 04 演示 3):

排序依据获批者中 group 1 的份额group 1 获批比例same-risk gap
用 yobsy_\text{obs} 训练的模型11.2%0.188−0.247
用真实 yy 训练的模型21.0%0.353+0.007
oracle(真实还款概率)20.5%0.3440.000

7.4 误差的结构决定了哪个指标被骗

我们最初设计的误记方式不是上面这种,而是”group 1 的每个按时还款以固定概率被随机记成违约,与特征无关”。结果和预想不同(见代码 README):审计员并没有看到”公平”。代码 04 演示 4 把两种机制放在一起比较(strength = shift 的 logit 折扣或 flip 的误记概率):

机制strengthcal_gap(yobsy_\text{obs} / 真实)EOD(yobsy_\text{obs} / 真实)PPV_diff(yobsy_\text{obs} / 真实)
shift0.50.017 / 0.084−0.200 / −0.238−0.107 / −0.009
shift1.00.039 / 0.161−0.341 / −0.432−0.109 / +0.040
shift1.50.037 / 0.258−0.449 / −0.585−0.135 / +0.073
flip0.10.050 / 0.065−0.200 / −0.194−0.107 / −0.029
flip0.20.108 / 0.110−0.300 / −0.293−0.171 / +0.006
flip0.30.099 / 0.199−0.431 / −0.433−0.211 / +0.040
  • shift(Obermeyer 型):校准检查失灵(yobsy_\text{obs} 下 cal_gap 始终 ≤ 0.04,真实的增长到 0.258),EOD 被低估,PPV_diff 甚至方向相反。
  • flip(随机误记):EOD 在两种标签下几乎一样 —— 被误记的好人是所有好人的随机子集,“好人里被批准的比例”不受影响(练习 5 让你证明)。但 PPV 被系统性地压低(PPVobs=(1−ρ) PPV\text{PPV}_\text{obs} = (1 - \rho)\,\text{PPV}),所以 PPV_diff 在 yobsy_\text{obs} 下是一个大的负数,真实情况接近 0。

Lesson: which metric is distorted, and in which direction, depends on the structure of the measurement error — whether it is random or related to the features, and whether the model can absorb it. Before reporting any separation or sufficiency metric, ask: does this label measure what we care about? Are its errors the same across groups? Do they depend on the features?

7.5 其他测量问题

  • Selective labels(Lakkaraju et al. 2017):贷款只有被批准了才能观察到”还不还”;保释只有被释放了才能观察到”会不会再犯”。训练和审计都只能用到历史上获批的人,而他们是被一个可能有偏的过程选出来的。
  • Feedback loops:模型的决定改变了未来的数据(被拒的人没有机会建立信用记录,下一次更容易被拒)。第 1 讲的 thin-file 效应在现实中部分就是这样形成的。
  • 缺失的群体标签:见 §9.3。

8. Corbett-Davies & Goel 的批评 · The measure and mismeasure of fairness

8.1 Three formal definitions, three limitations

Corbett-Davies & Goel (2018), the fourth reading, group the popular definitions into three families and argue that all three suffer from significant statistical limitations:

FamilyDefinitionTheir critique
Anti-classificationprotected attributes (and their proxies) are not used to form predictionscan harm the group it aims to protect (§8.4)
Classification parityerror rates (FPR, FNR, …) or selection rates are equal across groupsignores inframarginality; can also harm the protected group (§8.3)
Calibrationoutcomes independent of the group, conditional on the scoregenerally desirable, but offers little assurance that decisions are equitable (§8.5)

8.2 Threshold rules

Their positive starting point is decision-theoretic. Suppose approving an applicant with repayment probability rr yields a gain gg if they repay and a loss ℓ\ell if they default. The expected utility is rg−(1−r)ℓr g - (1 - r)\ell, which is positive iff

r≥t∗=ℓg+ℓ.r \ge t^* = \frac{\ell}{g + \ell}.

So the utility-maximizing policy is a single threshold on calibrated risk, applied to everyone. Corbett-Davies et al. (2017) showed that if you add a classification-parity constraint (equal selection rates, equal FPRs), the optimal constrained policy uses group-specific thresholds — which means treating people with the same risk differently because of their group, i.e. something close to disparate treatment. This is the decision-theoretic version of the trade-off L1 §7.1 measured.

8.3 Inframarginality

Why not just equalize error rates? Because error rates depend on the whole distribution of risk in each group, not only on where the threshold is. With one threshold tt,

FPRa=P(R≥t∣Y=0,A=a),\text{FPR}_a = P(R \ge t \mid Y = 0, A = a),

which is larger in a group with more defaulters sitting just above the threshold. L1 §7.1 showed it with the oracle: the same threshold 0.5 applied to perfectly calibrated scores gives FPR 0.502 vs 0.374. Nobody was held to a different standard; the groups just have different risk distributions. This is the problem of inframarginality, first raised by Ayres (2002) for outcome tests of police searches and analyzed by Simoiu, Corbett-Davies & Goel (2017): averages over all people inside the margin don’t tell you whether the margin (the threshold) differs. Unequal error rates are therefore neither necessary nor sufficient evidence that a standard is unequal. 反过来,强行让 FPR 相等,就要对两个群体用不同的阈值 —— 在 group 1 里批准一些按同样标准本该被拒的人,或在 group 0 里拒绝一些本该被批的人。

8.4 Anti-classification can hurt

Their main example: in some jurisdictions, women reoffend less often than men with the same criminal history, so a gender-blind risk tool overstates women’s risk; using gender would make the scores more accurate and lead to fewer women being detained. Our §6.4 is the same phenomenon in credit: the group-blind model under-predicts group 1 because credit history means something different for them, and letting the model see the group (or even a proxy) shrinks the same-risk gap from −0.125 to −0.009. Unawareness controls what the model sees, not what it does to people.

8.5 Calibration is not enough

Calibration within groups looks like the most “neutral” criterion: a score of 0.7 means 70% for everyone. 代码 02 演示 3(b) 展示它可以被”钻空子”:base rate 0.6 vs 0.4,一个”偷懒”的分数对 group 0 用贝叶斯后验,对 group 1 完全不看特征,一律给 0.4(group 1 的 base rate):

分数ECE g0ECE g1AUC g1group 1 批准率 @0.5group 1 TPR @0.5group 1 准确率
诚实的 calibrated 分数0.0050.0020.8550.3640.6820.780
lazy(忽略 group 1 的特征)0.0050.0020.5000.0000.0000.602

两个分数在两个群体内部都完美 calibrated —— 任何 sufficiency 检查都会通过。但 lazy 分数对 group 1 毫无区分能力,阈值 0.5 下一个 group 1 申请人都不批,会还款的 group 1 申请人全部被拒。历史上的 redlining 就有这个结构:对某些街区的人不做个别评估,直接按街区的平均风险拒绝。Calibration 必须和每个群体内的区分能力(AUC)一起报告。

8.6 What they recommend, and its limits

Corbett-Davies & Goel’s recommendation: rather than imposing one of the three formal criteria, it is often preferable to treat similarly risky people similarly, based on the most statistically accurate estimates of risk one can produce — and then to reason explicitly about the consequences of the policy (who is approved, who is harmed, what alternatives exist). Our same-risk gap (§6.3) is a direct check of this principle.

But it rests on two premises that §6–§7 just showed can fail: the risk estimates must be accurate for each group (L1’s thin-file Model B isn’t), and the label that defines “risk” must be unbiased (§7’s yobsy_\text{obs} isn’t — a model can be perfectly “risk-calibrated” against a biased label). The paper itself discusses measurement error in the label and sample bias as the main practical difficulties. Their later, longer version (Corbett-Davies, Gaebler, Nilforoshan, Shroff & Goel, JMLR 2023) sharpens the argument: policies constrained by these formal definitions are typically strongly Pareto-dominated — some alternative policy is better on every objective the decision maker cares about (in their college-admissions example, a class that is both more diverse and better prepared).


9. 测量的困难 · Measuring fairness in practice

9.1 样本量与置信区间

第 1 讲 §8.1 已经说明:在”没有任何差别”的世界里,小样本也会”测出”差距。代码 01 演示 4 换一个角度:同一个 Model B、同一份数据的前 nn 个人,每个指标的 95% CI 宽度:

指标值 @4000CI 宽度 @4000值 @1000宽度 @1000值 @250宽度 @250
SPD−0.2650.059−0.2690.129−0.1910.236
DIR0.6810.0690.6770.1470.7720.271
EOD−0.1890.068−0.1690.131−0.1540.236
FPR_diff−0.2670.106−0.3020.219−0.2940.473
PPV_diff−0.0270.0730.0030.1280.0730.228
NPV_diff−0.0640.114−0.0520.221−0.1430.491
cal_gap0.0610.0470.1040.145——
  • 宽度大约按 1/n1/\sqrt n 变化。分母越小的指标越不确定:FPR_diff 的分母是”group 1 里会违约的人”(n=250n = 250 时只有 22 人),区间宽到 0.47,几乎什么也说明不了。
  • 点估计本身也在晃:n=250n = 250 时 DIR = 0.772,比全样本的 0.681 好看得多。小样本审计既可能冤枉一个模型,也可能放过它。
  • cal_gap 是”|差|“的平均,噪声只会让它变大(n=1000n = 1000 时 0.104);n=250n = 250 时没有任何分数区间两组各有 ≥ 30 人,根本算不出来。

实践建议:先数一数每个指标的分母有多少人,再决定能可靠地报告哪些指标。

9.2 交叉群体 · Intersectionality

Kimberlé Crenshaw (1989) coined intersectionality to describe how discrimination against Black women was invisible to legal analyses that looked at race and sex separately. Gender Shades (Buolamwini & Gebru 2018) found its starkest errors only after splitting by skin type and gender. 代码 05 演示 2 把群体和年龄段(年龄也是 ECOA 保护的属性;在我们的世界里它和信用历史相关)交叉,Model B,部署数据:

子群体n会还款的人批准率TPR95% Wilson CI平均预测 − 实际
group 0282020160.8310.933[0.921, 0.943]+0.017
group 111806970.5660.743[0.709, 0.774]−0.051
18-29 岁10366220.6180.793[0.759, 0.823]−0.022
40+ 岁8306280.8510.954[0.934, 0.968]+0.003
group 0 · 40+7215680.8810.967[0.948, 0.978]−0.003
group 1 · 18-295623260.5140.696[0.644, 0.744]−0.068
group 1 · 30-395093110.6050.775[0.725, 0.818]−0.051
group 1 · 40+109600.6510.833[0.720, 0.907]+0.041

(完整的 6 个交叉格子见代码输出。)TPR 的最大差距:按群体 0.189,按年龄段 0.161,按 6 个交叉格子 0.270。年轻的 group 1 申请人信用历史最短,而 Model B 对短历史的惩罚对 group 1 最不应该。最后一列更有意思:group 1 整体被低估(−0.051),但 18-29 岁被低估 0.068,40+ 反而被高估 0.041 —— 只按一个属性拆开,会把方向相反的两种错误平均掉。

可是格子越小,区间越宽:“group 1 · 40+“只有 60 个会还款的人,Wilson 区间宽 0.19,是 group 0 整体的近 10 倍。而且”最差子群体的差距”是一个 max,按本课的约定要报告噪声地板:把会还款的人的子群体标签随机打乱 1000 次(真实 TPR 完全相同的零假设世界),看”最大 − 最小”有多大:

审计样本量观测到的最大 TPR 差距零假设下的均值零假设下的 95% 分位最小格子的会还款人数
40000.2700.0540.09860
10000.2580.1120.20714

4000 人时 0.270 远超噪声地板;1000 人时只比它高一点。这是 Kearns, Neel, Roth & Wu (2018) 所说的 fairness gerrymandering 两难:只检查少数几个边际群体,可能漏掉交叉处的严重不公平(一个分类器可以在每个边际群体上都”公平”,却在交叉处不公平);检查成千上万个交叉子群体,又会被噪声和多重比较淹没。常见的折中:事先写下要检查哪些子群体,报告每个格子的样本量和置信区间,对”最差子群体”报告噪声地板。(Kearns et al. 和 Hébert-Johnson et al. 2018 的 multicalibration 给出了在大量子群体上同时审计和学习的算法。)

9.3 缺失的群体标签 · Missing group labels

To measure disparate impact you need to know who belongs to which group. Yet in US non-mortgage lending, Regulation B generally prohibits lenders from asking about race and similar attributes (mortgages have a dedicated monitoring exception). Regulators such as the CFPB therefore estimate race with BISG (Bayesian Improved Surname Geocoding: a probability from surname and address). Chen, Kallus, Mao, Svacha & Udell (2019) showed that disparities computed from such inferred labels are systematically biased — they can over- or under-state the true disparity, depending on how the inference variables relate to the outcome. The irony: BISG works precisely because surname and address are good proxies — the problem of §6 reappears on the measurement side.

9.4 报告时写清楚语境

一个公平数字至少要附带:哪个人群(部署 / 测试、哪段时间)、哪个阈值或策略、每个群体的样本量和 base rate、置信区间、用的是什么标签(以及它可能的测量误差)。第 1 讲 §8.4 的 model card 就是放这些信息的地方(§10.3 给一个模板)。


10. 怎样选一个指标 · How do we pick a fairness metric?

10.1 Five questions

The slides end the recap with “How do we pick a fairness metric?” and the COMPAS slide with: What’s worse — a non-violent person going to jail, or a violent person remaining free? There is no metric to rule them all, but there is a reasonable order of questions:

  1. What is the decision, and who bears which error? Assistive decisions (loans, extra care, scholarships): a false negative denies a qualified person a benefit → protect FNR / TPR (equal opportunity). Punitive decisions (detention, fraud freezes, child-welfare investigations): a false positive harms an innocent person → protect FPR. Both costly → equalized odds.
  2. Is the label trustworthy? If YY is a biased measurement (§7), separation and sufficiency inherit the bias. Fix or audit the label first; meanwhile, independence (label-free) is the only metric the bias can’t touch.
  3. Where do base-rate differences come from? If you believe they reflect real differences in the construct (WYSIWYG), error-rate and calibration metrics are natural. If you believe they are products of measurement or past injustice (WAE), demographic parity becomes more defensible. Say which you assume.
  4. What will the score be used for? If humans downstream read it as a probability (pricing, risk communication), calibration within groups matters — together with per-group AUC (§8.5).
  5. What does the law allow, and can you measure it? Group-specific thresholds may be disparate treatment; the group attribute may be unavailable (§9.3); small groups may make some metrics unmeasurable (§9.1).

10.2 课程里的场景

场景哪种错误伤害谁常见选择需要警惕
再犯风险(COMPAS)FP:没有再犯的人被拘押FPR 相等(ProPublica)vs calibration(Northpointe)标签是”再次被捕”而不是”再次犯罪”;COMPAS 的总体准确率只有约 61%
信贷 / 信用卡额度FN:有能力还款的人被拒equal opportunity(FNR 相等);监管看 DIRselective labels;thin file;四分之五规则用比值
招聘(Amazon 的简历模型)FN:合格的人被筛掉equal opportunity;法律看 selection rate标签是”过去被录用的人”—— 历史决定(§6.3)
大学录取FN:合格的人被拒;也关心群体构成equal opportunity 或 demographic parity考试分数是否测量同一个构念(WAE vs WYSIWYG)
人脸识别FP / FN 都可能(误认、无法解锁)各群体的错误率相等交叉群体(Gender Shades)
医疗资源分配(Obermeyer)FN:需要帮助的人没被选中按真实需求的 calibration、equal opportunity代理标签(花费 ≠ 需求)

Aequitas 工具包(Saleiro et al. 2018)把类似的问题画成了一棵 “fairness tree”:先问干预是惩罚性的还是辅助性的,再问资源是否稀缺、关心的是”所有人”还是”被选中的人”,最后落到一个具体指标。

10.3 把选择写下来 · A fairness section for a model card

Fairness evaluation
  Decision & stakes:   信贷审批;FN = 有能力还款的申请人被拒(主要伤害申请人)
  Protected attributes: group(来源:自报 / 推断?)、age bucket;交叉:group × age
  Primary metric:      EOD(TPR 差距);理由:辅助性决策,FN 的伤害最大
  Also reported:       SPD / DIR(四分之五规则)、FPR_diff、PPV_diff、各群体 ECE 与 AUC、base rates
  Population & time:   部署数据,2026 Q3,n = 4000(group 1:1180;group 1 中会还款的 697)
  Threshold:           0.5(单一阈值)
  Uncertainty:         95% bootstrap CI;子群体用 Wilson CI;最差子群体差距附噪声地板
  Label:               "24 个月内无逾期记录";已知问题:group 1 所在社区的逾期上报更激进(§7),审计用了独立的还款数据
  Known trade-offs:    base rate 不同 ⇒ 不能同时满足 calibration 与 equal opportunity(§4);选择了后者,代价是……
  Not evaluated:       representational harms;长期反馈效应

10.4 下一步:缓解

一旦知道了要量什么,就可以在三个阶段去改它(slides 的分类,第 6 讲展开):pre-processing(改数据:reweighing、Feldman 的分位数修复、counterfactual data augmentation)、in-processing(改训练:公平约束、adversarial debiasing —— 让一个对手无法从预测中猜出群体,HW3 的编程题)、post-processing(改决策:Hardt et al. 2016 的群体阈值与随机化)。每一种都”盯住”某一个指标;本讲的教训是:改一个,要同时看所有其他的。


11. 小结 · Summary

主题核心结论本讲的数字
三个准则几乎所有群体指标都是 independence / separation / sufficiency 之一;区别在分母和视角Model B:DIR 0.681、EOD −0.189,但 PPV 差只有 −0.027
不可能定理base rate 不同 + 分类器有信息量 ⇒ 最多满足一个;KMR:calibration + 两个 balance ⇒ base rate 相等或完美预测扫描中除 p0=p1p_0 = p_1 外没有一行出现两个 ✓
定理没说的base rate 相等是必要不充分条件;“全满足”可能只能靠 leveling downgroup 0 的 AUC 0.853 → 0.699
个体公平Lipschitz 条件把问题移进了相似度度量 dd;选 dd 就是选价值判断双胞胎决策不一致 9.1%(raw)vs 27.6%(pct)
Unawareness群体信息藏在代理里;有偏的标签会通过代理回到模型里,阈值化还会放大它群体可预测 AUC 0.955;unaware 复现 48%、+邮编 82% 的折扣
标签偏差依赖标签的指标最多和标签一样公平;被骗的方式取决于误差结构审计说 cal_gap 0.044,真相是低估 0.150
Corbett-Davies & Goel阈值规则、inframarginality、calibration 可被钻空子;“风险相同则对待相同”需要准确的风险和无偏的标签lazy 分数完美 calibrated,却拒绝所有 group 1
测量分母小的指标不可信;交叉群体更不公平也更不确定;“最差子群体”要报告噪声地板交叉差距 0.270;n = 1000 时噪声地板 0.207

Six takeaways:

  1. “Fair” is not one property. It is a family of conditional-independence statements, each encoding a different view of whose errors matter.
  2. When base rates differ, you must choose — mathematically, not just practically. Report the base rates before any metric.
  3. Individual fairness relocates the value judgment into the similarity metric; it doesn’t remove it.
  4. Unawareness controls inputs, not outcomes. Proxies carry whatever the label says about the group — bias or truth.
  5. Audit the label, not just the model. A model can be perfectly calibrated against a biased label.
  6. Every fairness number needs a population, a threshold, a sample size and a confidence interval — and the max over many subgroups needs a noise floor.

12. 常见误区 · Common pitfalls

  • “We don’t use the protected attribute, so we can’t be discriminating.” The group is predictable from other features (AUC 0.830 without zip, 0.955 with it), and biased labels flow through those proxies (§6).
  • “The model is calibrated in both groups, so it’s fair.” Calibration can hold for a score that ignores one group’s features entirely (§8.5) or that faithfully reproduces a biased label (§7.3). Check per-group AUC and the label.
  • “Equal error rates mean equal standards.” Inframarginality: one threshold on calibrated scores gives unequal FPRs (§8.3); equal FPRs may require different standards.
  • “DIR passes the four-fifths rule, so we’re fine.” The ratio depends on which outcome is called favorable and on the threshold (0.842 at t = 0.3, 0.485 at t = 0.7), and on sample noise (0.772 in a 250-person audit vs 0.681).
  • “Impossibility means we shouldn’t bother.” The theorems say you must choose and justify, not that all choices are equally good. Some disparities (model misspecification, label bias) are fixable errors, not trade-offs.
  • “The worst subgroup has a 0.26 gap, so it’s the most discriminated group.” With many small cells, a large max gap can be noise; compare with a permutation noise floor (§9.2).
  • “Equalizing everything is the safest choice.” Leveling down satisfies every criterion by making everyone worse off (§4.7).
  • “Average odds difference is 0, so error rates are balanced.” AOD averages a TPR gap and an FPR gap that can cancel; report both.

13. 练习 · Exercises

练习 1(Independence vs sufficiency,HW3 第 3 题). 证明:如果 Y⊥̸AY \not\perp A,那么 independence 和 sufficiency 不能同时成立。然后讨论:在信贷、招聘、再犯预测中,"Y⊥̸AY \not\perp A"这个假设合理吗?它的合理性取决于什么?

参考答案

证明见 §4.2:两者都成立时,P(Y=y∣A=a)=∑rP(Y=y∣R=r)P(R=r)=P(Y=y)P(Y = y \mid A = a) = \sum_r P(Y = y \mid R = r)P(R = r) = P(Y = y),与 Y⊥̸AY \not\perp A 矛盾。这个证明对任何 RR(分数或决策)都成立。

关于假设:在观测到的标签上,base rate 几乎总是不同的(第 1 讲的世界:0.715 vs 0.591)。但”观测到的 base rate 不同”和”构念上的能力不同”是两回事:如果标签本身有偏(§7)或者差异来自过去的不公正(WAE),那么 Y⊥̸AY \not\perp A 部分地是测量和历史的产物。所以这个假设在数学上几乎总是成立,在规范意义上却恰恰是争论的焦点 —— 它决定了”放弃 independence”是否可以接受。

练习 2(Independence vs separation,数值版). 一个分类器在两个群体里都有 TPR = 0.8、FPR = 0.2(separation 成立)。base rate p0=0.7p_0 = 0.7、p1=0.5p_1 = 0.5。(a) 计算两个群体的批准率和 DIR。(b) 计算两个群体的 PPV。(c) 这和 §4.3、§4.4 的证明有什么关系?

参考答案

(a) sel0=0.7×0.8+0.3×0.2=0.62\text{sel}_0 = 0.7 \times 0.8 + 0.3 \times 0.2 = 0.62,sel1=0.5×0.8+0.5×0.2=0.50\text{sel}_1 = 0.5 \times 0.8 + 0.5 \times 0.2 = 0.50,DIR = 0.806(刚好通过四分之五规则)。(b) PPV0=0.56/0.62=0.903\text{PPV}_0 = 0.56/0.62 = 0.903,PPV1=0.40/0.50=0.800\text{PPV}_1 = 0.40/0.50 = 0.800。(c) §4.3:批准率 =pa TPR+(1−pa) FPR=FPR+pa(TPR−FPR)= p_a\,\text{TPR} + (1 - p_a)\,\text{FPR} = \text{FPR} + p_a(\text{TPR} - \text{FPR}),只要 TPR ≠ FPR(分类器有信息量),它就随 pap_a 变化 —— independence 被违反。§4.4:Chouldechova 恒等式里 TPR、FPR 相等而 odds 不同,PPV 必然不同 —— sufficiency 被违反。一个 separation 成立的分类器,在 base rate 高的群体里批准得更多、批准的人也更”准”。

练习 3(KMR 直线). 一个分数在两个群体内都 calibrated,p0=0.7p_0 = 0.7、p1=0.5p_1 = 0.5。假设它满足 balance for the positive class:两个群体会还款的人平均得分都是 t=0.8t = 0.8。(a) 求两个群体会违约的人的平均得分 x0x_0、x1x_1。(b) 用一句话解释这个结果对”会违约的人”意味着什么。(c) 如果要让 x0=x1x_0 = x_1,tt 必须是多少?

参考答案

(a) 由 (1−p) x=p (1−t)(1 - p)\,x = p\,(1 - t):x0=(0.7/0.3)×0.2=0.467x_0 = (0.7/0.3)\times 0.2 = 0.467,x1=1×0.2=0.2x_1 = 1 \times 0.2 = 0.2。(b) 会违约的 group 0 申请人平均得到 0.467 分,group 1 只有 0.2 分:group 0 的”坏人”被系统性地给了更高的分(更容易被错批),而这是 calibration 在 base rate 不同时的必然结果,不是模型的错误。(c) x0=x1x_0 = x_1 ⇔ 73(1−t)=1−t\tfrac{7}{3}(1 - t) = 1 - t ⇔ t=1t = 1,此时 x=0x = 0:完美预测。这就是 §4.5 的定理。

练习 4(四分之五规则与不确定性). 一家公司收到 group 0 的 300 份申请,录用 90 人;group 1 的 100 份申请,录用 20 人。(a) 计算 DIR、SPD 和拒绝率之比。(b) 用 Wilson 公式计算 group 1 录用率的 95% 区间。(c) 这个”adverse impact”的结论有多稳健?

参考答案

(a) sel0=0.30\text{sel}_0 = 0.30,sel1=0.20\text{sel}_1 = 0.20;DIR = 0.667(不通过);SPD = −0.10;拒绝率之比 0.70/0.80=0.8750.70/0.80 = 0.875(如果以拒绝为比较对象,就”通过”了 —— §3.4 的陷阱)。(b) p^=0.2\hat p = 0.2,n=100n = 100,z=1.96z = 1.96:分母 1+z2/n=1.03841 + z^2/n = 1.0384,中心 (0.2+0.0192)/1.0384=0.211(0.2 + 0.0192)/1.0384 = 0.211,半宽 1.961.03840.0016+0.000096=0.078\frac{1.96}{1.0384}\sqrt{0.0016 + 0.000096} = 0.078,区间约 [0.133, 0.289]。(c) 只考虑 group 1 的不确定性,DIR 的取值范围大约是 0.44 到 0.96(还没算 group 0 的不确定性)—— 四分之五规则给出了”不通过”,但样本太小,不能排除差距只是噪声。这就是为什么法院除了四分之五规则还会看统计显著性,也是 §9.1 的教训。

练习 5(随机误记不改变 TPR). 假设 group 1 的每个真实正例以概率 ρ\rho 被独立地记成负例,而且是否误记与特征 XX、与决策 Y^\hat Y 都独立。证明:(a) 用 yobsy_\text{obs} 算的 TPR(期望意义下)等于真实 TPR;(b) PPVobs=(1−ρ) PPV\text{PPV}_\text{obs} = (1 - \rho)\,\text{PPV}。用这两个结论解释代码 04 演示 4(b) 里 EOD 和 PPV_diff 的表现。

参考答案

(a) 记 KK 为”没有被误记”的指示变量,K⊥(X,Y^)K \perp (X, \hat Y) 且 P(K=1)=1−ρP(K = 1) = 1 - \rho。yobs=1⇔Y=1,K=1y_\text{obs} = 1 \Leftrightarrow Y = 1, K = 1。所以 P(Y^=1∣yobs=1)=P(Y^=1∣Y=1,K=1)=P(Y^=1∣Y=1)P(\hat Y = 1 \mid y_\text{obs} = 1) = P(\hat Y = 1 \mid Y = 1, K = 1) = P(\hat Y = 1 \mid Y = 1)(KK 与 Y^\hat Y 独立)。观测到的正例只是真实正例的一个随机子集,“其中被批准的比例”不变。(b) P(yobs=1∣Y^=1)=P(Y=1∣Y^=1) P(K=1)=(1−ρ) PPVP(y_\text{obs} = 1 \mid \hat Y = 1) = P(Y = 1 \mid \hat Y = 1)\,P(K = 1) = (1 - \rho)\,\text{PPV}。

演示 4(b):strength 0.2 时 EOD 按 yobsy_\text{obs} 是 −0.300、按真实 yy 是 −0.293(几乎相同,差别是抽样噪声);而 group 1 的 PPV 被压低约 20%,于是 PPV_diff 按 yobsy_\text{obs} 是 −0.171、按真实 yy 只有 +0.006。注意演示 4(a) 的 shift 型误记和 XX 有关(越接近边界的人越容易被误记),(a) 的独立性假设不成立,所以 EOD 也被扭曲了。

练习 6(选一个指标). 为下面两个应用各写一段 fairness 评估方案(参考 §10.3 的模板):(i) 一个城市用模型挑选住户,主动上门提供免费的房屋维修服务(名额有限);(ii) 一家银行的反欺诈模型,自动冻结可疑账户直到人工复核。说明:哪种错误更严重、对谁;主指标和辅助指标;标签可能有什么问题;需要多大的样本。

参考答案(要点)

(i) 辅助性、资源稀缺。最严重的错误是 FN:需要维修的住户没被选中。主指标:按”真实需求”的 equal opportunity(TPR 差距),辅以 selection rate(WAE 视角下的群体份额)和固定名额下各群体的份额(§7.3 的表)。标签问题和 Obermeyer 完全同构:如果用”过去的维修报修次数 / 花费”当需求的代理,不常报修的社区(语言障碍、对政府的不信任、租户怕房东)会被系统性低估 —— 需要独立的需求测量(实地抽样检查)。样本量:按街区和人群交叉的格子可能很小,事先确定子群体,报告 Wilson 区间。

(ii) 惩罚性。最严重的错误是 FP:无辜用户的账户被冻结(可能付不了房租)。主指标:FPR 差距(以及冻结时长的差距),辅以 PPV(被冻结的人里真的欺诈的比例)。标签问题:只有被调查过的账户才有”确认欺诈”标签(selective labels),而调查本身可能集中在某些群体上,使那些群体的”欺诈率”被高估。还要注意 inframarginality:FPR 不同不一定说明标准不同,要同时看各群体的风险分布和阈值附近的情况。两个应用都要写明阈值、人群、时间段,以及”不在评估范围内”的东西。

代码相关的练习(“动手改一改”)见 code/lecture05/README.md。


14. 延伸阅读 · Further reading

本讲的主要来源(Spring 2022 第 4 周阅读材料与 slides)

  • CS329T Spring 2022 slides “Fairness in ML”(2022-04-19、2022-04-26),HW3,Lab 4。
  • Barocas & Selbst, “Big Data’s Disparate Impact”, California Law Review 104, 2016。
  • Feldman, Friedler, Moeller, Scheidegger & Venkatasubramanian, “Certifying and Removing Disparate Impact”, KDD 2015。
  • Dwork, Hardt, Pitassi, Reingold & Zemel, “Fairness through Awareness”, ITCS 2012。
  • Corbett-Davies & Goel, “The Measure and Mismeasure of Fairness: A Critical Review of Fair Machine Learning”, arXiv 2018;扩展版 Corbett-Davies, Gaebler, Nilforoshan, Shroff & Goel, JMLR 2023。

定义与不可能定理

  • Barocas, Hardt & Narayanan, Fairness and Machine Learning: Limitations and Opportunities(MIT Press 2023,fairmlbook.org),第 3 章(classification)。
  • Kleinberg, Mullainathan & Raghavan, “Inherent Trade-Offs in the Fair Determination of Risk Scores”, ITCS 2017;Chouldechova, “Fair Prediction with Disparate Impact”, Big Data 2017。
  • Hardt, Price & Srebro, “Equality of Opportunity in Supervised Learning”, NeurIPS 2016;Pleiss et al., “On Fairness and Calibration”, NeurIPS 2017。
  • Friedler, Scheidegger & Venkatasubramanian, “On the (Im)possibility of Fairness”, arXiv 2016(CACM 2021)。
  • Zemel et al., “Learning Fair Representations”, ICML 2013;Kusner et al., “Counterfactual Fairness”, NeurIPS 2017。
  • Mitchell, Potash, Barocas, D’Amour & Lum, “Algorithmic Fairness: Choices, Assumptions, and Definitions”, Annual Review of Statistics and Its Application 2021;Narayanan, “21 Fairness Definitions and Their Politics”(FAT* 2018 tutorial)。

代理、标签与测量

  • Obermeyer, Powers, Vogeli & Mullainathan, “Dissecting Racial Bias in an Algorithm Used to Manage the Health of Populations”, Science 2019。
  • Jacobs & Wallach, “Measurement and Fairness”, FAccT 2021;Lakkaraju et al., “The Selective Labels Problem”, KDD 2017。
  • Lipton, McAuley & Chouldechova, “Does Mitigating ML’s Impact Disparity Require Treatment Disparity?”, NeurIPS 2018;Kleinberg, Ludwig, Mullainathan & Rambachan, “Algorithmic Fairness”, AEA Papers and Proceedings 2018。
  • Dutta, Venkatesh, Mardziel, Datta & Grover, “Fairness Under Feature Exemptions: Counterfactual and Observational Measures”, arXiv 2020(slides 引用)。
  • Chen, Kallus, Mao, Svacha & Udell, “Fairness Under Unawareness: Assessing Disparity When Protected Class Is Unobserved”, FAT* 2019。
  • Simoiu, Corbett-Davies & Goel, “The Problem of Infra-Marginality in Outcome Tests for Discrimination”, Annals of Applied Statistics 2017;Corbett-Davies et al., “Algorithmic Decision Making and the Cost of Fairness”, KDD 2017。

交叉群体与审计

  • Crenshaw, “Demarginalizing the Intersection of Race and Sex”, 1989;Buolamwini & Gebru, “Gender Shades”, FAT* 2018。
  • Kearns, Neel, Roth & Wu, “Preventing Fairness Gerrymandering”, ICML 2018;Hébert-Johnson et al., “Multicalibration”, ICML 2018。
  • 工具:IBM AIF360(Bellamy et al. 2018)、Aequitas(Saleiro et al. 2018)、Fairlearn。

15. 下一讲预告 · Next lecture

Lecture 6:缓解偏差(Mitigating Bias)。

本讲回答了”量什么、为什么不能全要、测量会在哪里骗人”。第 6 讲回答”量出来之后怎么改”:在数据阶段(reweighing、Feldman 的分位数修复、counterfactual data augmentation)、训练阶段(公平约束;HW3 的 adversarial debiasing —— 让一个对手无法从预测中猜出群体,demographic parity 版只给对手看预测,equality of opportunity 版还给它看真实标签)、决策阶段(Hardt et al. 的群体阈值与随机化)分别能做什么、代价是什么。我们还会进入 NLP:词向量里的性别方向、WEAT、hard debiasing 及其局限,以及 bias amplification —— 本讲 §6.3 里”模型比信贷员更偏”的现象,在图像标注和深度网络里有更系统的版本(Zhao et al. 2017;Leino et al. 2019 的 feature-wise bias amplification)。贯穿始终的一条纪律来自本讲:改善一个指标时,要同时报告所有其他指标。

← 返回课程目录