Fairness isn't a feeling; it's a metric. By formalizing our ethical goals into equations, we can audit and optimize models for objective equality.
1Equal Outcomes
Demographic Parity is a metric that ignores the 'correctness' of a prediction and focuses only on the 'Outcome'. It requires that the probability of a positive outcome (like getting a loan) is the same for all protected groups. This is often used in social policy to ensure that groups that have been historically disadvantaged receive an equal share of opportunities, regardless of current 'eligibility' metrics.
// Demographic Parity Concept
function checkDemographicParity(predictions, groups) {
let rateA = calculatePositiveRate(predictions, groups.A);
let rateB = calculatePositiveRate(predictions, groups.B);
// P(Y=1 | A) == P(Y=1 | B)
let disparity = Math.abs(rateA - rateB);
return disparity <= THRESHOLD;
}2Equal Error Rates
Equal Opportunity focuses on the 'Qualified' individuals. It requires that the True Positive Rate (TPR) is the same across all groups. This means that if you *actually* deserve the loan, the AI should have the same probability of approving you regardless of your group membership. This is often preferred in business contexts because it ensures the model's accuracy is 'Fair' without mandating equal raw outcomes for groups with different base characteristics.
// Equal Opportunity Concept
function checkEqualOpportunity(preds, labels, groups) {
let tprA = calculateTPR(preds, labels, groups.A);
let tprB = calculateTPR(preds, labels, groups.B);
// P(Y_hat=1 | Y=1, A) == P(Y_hat=1 | Y=1, B)
let disparity = Math.abs(tprA - tprB);
return disparity <= THRESHOLD;
}3The Mathematical Conflict
The Impossibility Theorem of Fairness states that unless the 'Base Rates' (the percentage of true positives) are exactly the same for all groups, you cannot satisfy all fairness metrics at once. For example, if Group A has 10% defaults and Group B has 50% defaults, a model cannot achieve both Demographic Parity *and* Predictive Parity. As an engineer, you must facilitate an Ethical Choice about which form of fairness is most important for your specific user base.
// The Impossibility Trade-off
function selectFairnessMetric(policyGoal) {
if (policyGoal === "EQUAL_REPRESENTATION") {
return calculateDemographicParity();
}
else if (policyGoal === "ACCURATE_REWARD") {
return calculateEqualOpportunity();
}
// You cannot return both if base rates differ.
}