[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,95 +2,286 @@
|
||||
id: wiki-2026-0508-algorithmic-fairness
|
||||
title: Algorithmic Fairness
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-ALFA-001]
|
||||
aliases: [AI fairness, ML bias, fair ML, algorithmic bias, group fairness]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.96
|
||||
tags: [auto-reinforced, algorithmic-fairness, bias, Equality, machine-learning-ethics, data-governance]
|
||||
source_trust_level: B
|
||||
confidence_score: 0.85
|
||||
verification_status: conceptual
|
||||
tags: [fairness, bias, ml-ethics, disparate-impact, audit, ai-governance, compas, gender-shades]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-09
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
---
|
||||
|
||||
# [[Algorithmic Fairness|Algorithmic Fairness]]
|
||||
# Algorithmic Fairness
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "데이터에 깃든 차별 걷어내기: AI가 성별, 인종, 계층에 대한 편향을 학습하여 누군가에게 불이익을 주지 않도록, 학습 데이터부터 결과 도출까지 모든 과정의 공정성을 확보하는 엔지니어링 윤리."
|
||||
## 📌 한 줄 통찰
|
||||
> **"매 group 의 differential impact 의 measure + mitigate"**. 매 ML system 의 bias = data + algorithm + deployment. **Pre-processing / In-processing / Post-processing** 의 3 stage 의 fairness intervention.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
알고리즘 공정성(Algorithmic Fairness)은 AI 모델의 예측 결과가 특정 집단에 대해 체계적으로 유리하거나 불리하지 않도록 관리하는 머신러닝의 하위 분야입니다.
|
||||
## 📖 핵심
|
||||
|
||||
1. **편향의 출처**:
|
||||
* **Data Bias**: 학습 데이터 자체가 기존 사회의 편견이나 불평등을 반영하고 있는 경우.
|
||||
* **Metric Bias**: 성과를 측정하는 지표(예: 클릭률) 자체가 특정 집단에 유리하게 설계된 경우.
|
||||
2. **공정성 메트릭**:
|
||||
* **Demographic Parity**: 모든 집단에 대해 긍정적인 예측 결과 비율이 같아야 함.
|
||||
* **Equalized Odds**: 오답률(FP, FN)이 집단별로 균등해야 함.
|
||||
3. **대응 기법**:
|
||||
* **Pre-[[Processing|Processing]]**: 학습 전 데이터를 재가공하여 균형 맞춤.
|
||||
* **In-processing**: 학습 과정에서 공정성 제약 조건(Penalty) 추가.
|
||||
* **Post-processing**: 결과 도출 후 편향이 감지되면 보정.
|
||||
### 매 fairness 의 definition
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 알고리즘의 '수학적 객관성' 정책만 믿었으나, 현대 정책은 '객관적인 데이터가 곧 공정한 결과는 아니다'라는 인식을 바탕으로 '적극적 불평등 시정 정책'을 모델에 주입함(RL Update).
|
||||
- **정책 변화(RL Update)**: 채용, 대출 심사, 형량 예측 등 민감한 공공 서비스 정책에서 사용되는 알고리즘은 의무적으로 '공정성 영향 평가(Fairness Audit)'를 통과해야 하는 정책이 수립됨.
|
||||
#### 1. Group fairness
|
||||
- **Demographic parity**: 매 group 의 same positive rate.
|
||||
- **Equal opportunity**: 매 group 의 same TPR.
|
||||
- **Equalized odds**: TPR + FPR 둘 다 same.
|
||||
- **Calibration**: 매 score 의 same meaning.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Toxicity-and-Bias-Mitigation|Toxicity-and-Bias-Mitigation]], [[AI Accountability|AI Accountability]], [[AI Governance|AI Governance]], [[Ethics & AI|Ethics & AI]], [[Sociology of Knowledge|Sociology of Knowledge]]
|
||||
- **Modern Tech/Tools**: IBM AI Fairness 360, Google What-If Tool, Fairlearn.
|
||||
---
|
||||
→ 매 mathematically incompatible (impossibility theorem).
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
#### 2. Individual fairness
|
||||
- 매 similar individual 의 similar treatment.
|
||||
- "Similar" 의 definition 어려움.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
#### 3. Counterfactual fairness
|
||||
- 매 prediction 의 unchanged if protected attribute 변경.
|
||||
- 매 causal model 필요.
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### 매 famous case
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
#### COMPAS (recidivism)
|
||||
- ProPublica 2016.
|
||||
- 매 black defendant 의 false positive rate 2x.
|
||||
- 매 risk score 의 racial bias.
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
#### Gender Shades (face recognition)
|
||||
- Joy Buolamwini, Timnit Gebru 2018.
|
||||
- 매 dark-skinned female 의 error rate 35% (vs light male 1%).
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
#### Amazon hiring AI (2018)
|
||||
- 매 resume + woman keyword 의 penalty.
|
||||
- 매 historical bias 의 reproduce.
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
→ 매 abandon.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
#### Apple Card (2019)
|
||||
- 매 credit limit 의 woman 의 lower (same financial profile).
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
#### Healthcare risk score (2019)
|
||||
- 매 black patient 의 lower risk score (same need).
|
||||
- 매 historical 의 healthcare expenditure (proxy bias).
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
### 매 source of bias
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
#### Data
|
||||
- **Historical**: 매 past discrimination.
|
||||
- **Representation**: 매 underrepresented group.
|
||||
- **Measurement**: 매 different signal quality per group.
|
||||
|
||||
```text
|
||||
# TODO
|
||||
#### Algorithm
|
||||
- 매 objective function 의 majority bias.
|
||||
- 매 feature selection.
|
||||
- 매 hyperparameter tuning.
|
||||
|
||||
#### Deployment
|
||||
- 매 user feedback loop.
|
||||
- 매 differential adoption.
|
||||
- 매 contextual mismatch.
|
||||
|
||||
### 매 mitigation strategy
|
||||
|
||||
#### Pre-processing (data)
|
||||
- 매 reweight sample.
|
||||
- 매 generate synthetic minority.
|
||||
- 매 protected attribute 의 remove (often insufficient — proxy).
|
||||
|
||||
#### In-processing (training)
|
||||
- 매 fairness constraint 의 add to loss.
|
||||
- Adversarial debiasing.
|
||||
- 매 prejudice remover.
|
||||
|
||||
#### Post-processing (output)
|
||||
- 매 threshold 의 group-specific.
|
||||
- 매 score calibration.
|
||||
- Rejection option classification.
|
||||
|
||||
### 매 audit / measurement
|
||||
|
||||
#### Disparate impact
|
||||
- 4/5 rule (US EEOC).
|
||||
- 매 minority 의 selection rate < 80% of majority = potential discrimination.
|
||||
|
||||
#### AIF360 (IBM)
|
||||
- 매 70+ fairness metric.
|
||||
- 매 9 mitigation algorithm.
|
||||
- Open source.
|
||||
|
||||
#### Aequitas (Univ. Chicago)
|
||||
- 매 audit toolkit.
|
||||
|
||||
#### Google What-If Tool
|
||||
- 매 interactive exploration.
|
||||
|
||||
### 매 regulation
|
||||
- **EU AI Act**: 매 high-risk 의 bias check.
|
||||
- **NYC Local Law 144**: hiring AI 의 annual audit.
|
||||
- **EEOC** (US): employment discrimination.
|
||||
- **GDPR Article 22**: 매 automated decision 의 human review.
|
||||
|
||||
### 매 organizational practice
|
||||
|
||||
#### Pre-deployment
|
||||
- 매 audit.
|
||||
- 매 disparate impact analysis.
|
||||
- 매 adversarial test.
|
||||
- 매 model card 의 disclosure.
|
||||
|
||||
#### Production
|
||||
- 매 monitoring.
|
||||
- 매 user feedback.
|
||||
- 매 quarterly review.
|
||||
|
||||
#### Incident
|
||||
- 매 user 의 complaint.
|
||||
- 매 root cause.
|
||||
- 매 remediation.
|
||||
|
||||
## 💻 Code
|
||||
|
||||
### Disparate impact (AIF360)
|
||||
```python
|
||||
from aif360.datasets import BinaryLabelDataset
|
||||
from aif360.metrics import BinaryLabelDatasetMetric, ClassificationMetric
|
||||
|
||||
# Wrap your dataset
|
||||
dataset = BinaryLabelDataset(
|
||||
df=df,
|
||||
label_names=['hired'],
|
||||
protected_attribute_names=['gender'],
|
||||
favorable_label=1,
|
||||
unfavorable_label=0,
|
||||
)
|
||||
|
||||
# Pre-train metric
|
||||
metric = BinaryLabelDatasetMetric(
|
||||
dataset,
|
||||
unprivileged_groups=[{'gender': 0}],
|
||||
privileged_groups=[{'gender': 1}],
|
||||
)
|
||||
print(f"Disparate impact: {metric.disparate_impact()}")
|
||||
# < 0.8 = potential bias (4/5 rule)
|
||||
|
||||
# After model: classification metric
|
||||
classified = BinaryLabelDataset(...) # with predictions
|
||||
clf_metric = ClassificationMetric(
|
||||
dataset, classified,
|
||||
unprivileged_groups=[{'gender': 0}],
|
||||
privileged_groups=[{'gender': 1}],
|
||||
)
|
||||
print(f"Equal opportunity diff: {clf_metric.equal_opportunity_difference()}")
|
||||
print(f"Avg odds diff: {clf_metric.average_odds_difference()}")
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Reweighting (pre-processing)
|
||||
```python
|
||||
from aif360.algorithms.preprocessing import Reweighing
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
rw = Reweighing(
|
||||
unprivileged_groups=[{'gender': 0}],
|
||||
privileged_groups=[{'gender': 1}],
|
||||
)
|
||||
dataset_rw = rw.fit_transform(dataset)
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
# Train on reweighted data
|
||||
model = train(dataset_rw)
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Adversarial debiasing (in-processing)
|
||||
```python
|
||||
from aif360.algorithms.inprocessing import AdversarialDebiasing
|
||||
import tensorflow as tf
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
sess = tf.Session()
|
||||
debiased = AdversarialDebiasing(
|
||||
privileged_groups=[{'gender': 1}],
|
||||
unprivileged_groups=[{'gender': 0}],
|
||||
scope_name='debiased',
|
||||
debias=True,
|
||||
sess=sess,
|
||||
)
|
||||
debiased.fit(dataset_train)
|
||||
preds = debiased.predict(dataset_test)
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Threshold optimization (post-processing)
|
||||
```python
|
||||
from aif360.algorithms.postprocessing import EqOddsPostprocessing
|
||||
|
||||
eq_odds = EqOddsPostprocessing(
|
||||
unprivileged_groups=[{'gender': 0}],
|
||||
privileged_groups=[{'gender': 1}],
|
||||
)
|
||||
eq_odds.fit(dataset_val, predictions_val)
|
||||
predictions_balanced = eq_odds.predict(predictions_test)
|
||||
```
|
||||
|
||||
### Fairness in CI
|
||||
```python
|
||||
def fairness_test(model, X_test, y_test, groups):
|
||||
"""매 release 의 fairness gate."""
|
||||
accuracies = {}
|
||||
for group_value in np.unique(groups):
|
||||
mask = groups == group_value
|
||||
accuracies[group_value] = model.score(X_test[mask], y_test[mask])
|
||||
|
||||
disparity = max(accuracies.values()) - min(accuracies.values())
|
||||
if disparity > 0.05:
|
||||
raise FairnessFailure(f"Disparity: {disparity:.2%}")
|
||||
```
|
||||
|
||||
### Counterfactual test
|
||||
```python
|
||||
def counterfactual_test(model, instance, protected_attr='gender'):
|
||||
"""매 attribute 의 flip 의 prediction change."""
|
||||
pred_original = model.predict([instance])
|
||||
|
||||
flipped = instance.copy()
|
||||
flipped[protected_attr] = 1 - flipped[protected_attr]
|
||||
pred_flipped = model.predict([flipped])
|
||||
|
||||
if pred_original != pred_flipped:
|
||||
return f"Bias detected: {protected_attr} flip changes prediction"
|
||||
```
|
||||
|
||||
## 🤔 결정 기준
|
||||
|
||||
| Risk level | Mitigation |
|
||||
|---|---|
|
||||
| Low (spam filter) | Audit log + monitor |
|
||||
| Medium (recommendation) | + Disparate impact check |
|
||||
| High (hiring, lending) | + Pre/in/post-processing |
|
||||
| Critical (criminal justice, medical) | + Strict regulation + human review |
|
||||
|
||||
**기본값**: 4/5 rule check + per-group accuracy + counterfactual test + disclosure.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[AI-Ethics]] · [[ML-Fairness]] · [[AI-Accountability]]
|
||||
- 변형: [[Group-Fairness]] · [[Individual-Fairness]] · [[Counterfactual-Fairness]]
|
||||
- 응용: [[COMPAS-Recidivism]] · [[Gender-Shades]] · [[Amazon-Hiring-AI]]
|
||||
- Tools: [[AIF360-IBM]] · [[Fairlearn-Microsoft]] · [[Aequitas]] · [[What-If-Tool-Google]]
|
||||
- 정책: [[EU-AI-Act-Bias]] · [[NYC-LL144]] · [[EEOC-4-5-Rule]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 ML system 의 deployment review. 매 audit. 매 high-risk 의 design.
|
||||
**언제 X**: Specific legal advice (lawyer). Specific implementation 의 detail.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **"Just remove protected attribute"**: 매 proxy 의 still bias.
|
||||
- **Single fairness metric**: 매 trade-off 의 ignore.
|
||||
- **No audit**: silent bias.
|
||||
- **Historical data 의 trust**: 매 past discrimination 의 amplify.
|
||||
- **Disparate impact 의 fix only**: 매 individual 의 unfair still.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified.
|
||||
- 신뢰도 B (academic + industry consensus).
|
||||
- Related: [[AI-Accountability]] · [[AI-Governance-Policy]].
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-09 | Manual cleanup — fairness type + famous case + AIF360 code + 결정 |
|
||||
|
||||
Reference in New Issue
Block a user