Responsible AI: Fairness, Bias, and Interpretability Questions
Building ML and AI systems that are fair, explainable, and safe. Covers identifying and mitigating bias, fairness metrics and tradeoffs, model interpretability and explainability techniques, label-bias feedback loops, and responsible and safe development practices for production models. Emphasizes accountability and transparency as first-class design constraints.
Explain why bias and fairness matter when models are used for hiring or lending decisions. As a data analyst, describe three quantitative checks you would run to surface potential bias, including the metric and example SQL or pseudocode for each, and how you would escalate findings to legal or compliance.
Sample Answer
Direct answer
Bias and fairness matter in hiring and lending specifically because these are consequential, often legally protected decisions: an unfair model can systematically deny someone a job or a loan for reasons correlated with a protected characteristic rather than merit or creditworthiness, which is both a real harm to the individual and, in the United States and many other jurisdictions, a legal liability for the organization (disparate-impact doctrine, industry-specific regulation like fair-lending law, and increasingly AI-specific audit requirements). As a data analyst, the three quantitative checks I would run first are: (1) the selection-rate ratio (the 80%/four-fifths rule) between groups, (2) a within-tier disparity check that compares outcome rates for groups AFTER controlling for a legitimate qualifying variable, and (3) an outcome-parity-within-score-band check (for lending specifically, whether the actual default rate matches across groups at the same approved risk tier, the calibration-by-group idea applied with plain SQL).
Structured elaboration
Why this matters, concretely. A hiring or lending model's decision changes a person's income, career trajectory, or access to capital, so an error is not a neutral misclassification, it is a material harm concentrated on whichever group the model is worse for. Beyond the moral case, hiring is governed in the United States by Title VII of the Civil Rights Act (the disparate-impact doctrine from Griggs v. Duke Power Co., 1971, operationalized by the EEOC's four-fifths rule) and, for algorithmic tools specifically, laws like New York City's Local Law 144 requiring independent bias audits; lending is governed by the Equal Credit Opportunity Act and the Fair Housing Act, both of which reach facially neutral scoring models that produce a disparate impact on a protected class. A data analyst surfacing a quantitative disparity early, before a model goes into production or during routine monitoring, is often the first and cheapest point at which the organization can catch and fix a problem that is much more expensive to fix (and to explain to a regulator) after the fact.
Check 1: selection-rate ratio (the 80% / four-fifths rule). This is the standard first-pass adverse-impact screen: compare the fraction of each group that receives a favorable outcome (hired, approved), and flag if the ratio of the lower rate to the higher rate falls below 0.8.
SELECT group_name,
COUNT(*) AS n,
SUM(hired) AS n_hired,
ROUND(1.0 * SUM(hired) / COUNT(*), 4) AS selection_rate
FROM applicants
GROUP BY group_name;
-- then in application code (or a HAVING-style follow-up query):
-- adverse_impact_ratio = MIN(selection_rate) / MAX(selection_rate); flag if < 0.8
Check 2: outcome disparity WITHIN a legitimate qualification tier. The raw selection-rate ratio can be confounded by a real difference in the underlying qualification distribution between groups; this check buckets applicants into qualification tiers first (a legitimate, job-relevant variable) and then compares hire rates by group WITHIN each tier, which isolates whether the model treats similarly-qualified people differently by group.
SELECT
CASE WHEN qualification_score < 40 THEN 'low'
WHEN qualification_score < 70 THEN 'mid'
ELSE 'high' END AS qual_tier,
group_name,
COUNT(*) AS n,
ROUND(1.0 * SUM(hired) / COUNT(*), 4) AS hire_rate
FROM applicants
GROUP BY qual_tier, group_name
ORDER BY qual_tier, group_name;
Check 3: outcome parity within the same approved score band (lending-specific calibration check). For lending, the analogous check is whether, among applicants approved at the SAME credit-score band (so already conditioned on the model's own risk assessment), the actual default rate matches across groups. If group B defaults noticeably less often than group A within the identical approved band, the model is systematically over-estimating group B's risk relative to reality, a real cost to that group even though the bank's own approval decision "looks" consistent by band.
SELECT score_band, group_name,
SUM(approved) AS n_approved,
SUM(defaulted) AS n_defaulted,
ROUND(1.0 * SUM(defaulted) / NULLIF(SUM(approved), 0), 4) AS default_rate_given_approved
FROM loans
GROUP BY score_band, group_name
ORDER BY score_band, group_name;
Escalating findings to legal or compliance. A quantitative flag from any of these checks is evidence, not a verdict, so the escalation process matters as much as the check itself:
- Document the exact query, the time window, the sample size per group and per stratum, and the computed ratio or gap, so the finding is reproducible by someone else, including legal or an external auditor.
- Route the finding through the established fairness/compliance review channel (a model-risk or responsible-AI review board where one exists) rather than an ad hoc email, and flag the confidence level: a ratio computed on a stratum with a handful of applicants needs a caveat about statistical noise, not just the raw number.
- Do NOT attempt to unilaterally "fix" the model's outputs to correct the ratio before legal has weighed in; an analyst-initiated output adjustment based on group membership can itself introduce disparate-treatment exposure (the Ricci v. DeStefano, 2009 pattern), so the analyst's job is to surface and document the disparity accurately, and legal/compliance owns deciding the remediation path and any required external reporting.
- Propose next-step analyses that legal is likely to need (a job-relatedness/business-necessity check on whichever feature seems to be driving check 2's within-tier gap, or a same-quarter historical comparison to see if the gap is new or persistent) so the escalation includes actionable follow-up, not just a flagged number.
Worked example
Running the three checks against a synthetic dataset (300 hiring applicants and 1,200 loan records per group, seeded for reproducibility) gives concrete, checkable numbers:
import sqlite3
import numpy as np
rng = np.random.default_rng(11)
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
cur.execute("""CREATE TABLE applicants (id INTEGER PRIMARY KEY, group_name TEXT,
qualification_score REAL, hired INTEGER)""")
cur.execute("""CREATE TABLE loans (id INTEGER PRIMARY KEY, group_name TEXT,
score_band TEXT, approved INTEGER, defaulted INTEGER)""")
n_per_group = 300
for grp, hire_bonus in [("A", 0.0), ("B", -0.18)]:
quals = rng.normal(60, 15, size=n_per_group).clip(0, 100)
tiers = np.digitize(quals, bins=[40, 70])
base_rate_by_tier = np.array([0.15, 0.45, 0.80])
hire_prob = np.clip(base_rate_by_tier[tiers] + hire_bonus, 0, 1)
hired = rng.binomial(1, hire_prob)
for q, h in zip(quals, hired):
cur.execute("INSERT INTO applicants (group_name, qualification_score, hired) VALUES (?,?,?)",
(grp, float(q), int(h)))
bands = ["600-649", "650-699", "700-749", "750+"]
band_default_base = {"600-649": 0.30, "650-699": 0.18, "700-749": 0.09, "750+": 0.03}
for grp, default_multiplier in [("A", 1.0), ("B", 0.65)]:
for band in bands:
approved = rng.binomial(1, 0.7, size=150)
defaulted = np.where(approved == 1,
rng.binomial(1, band_default_base[band] * default_multiplier, size=150), 0)
for a, d in zip(approved, defaulted):
cur.execute("INSERT INTO loans (group_name, score_band, approved, defaulted) VALUES (?,?,?,?)",
(grp, band, int(a), int(d)))
conn.commit()
# ... run the three SELECT queries above via cur.execute(...) ...
Executing check 1's query returns group A at a 49.0% selection rate (147/300) and group B at 36.67% (110/300), an adverse-impact ratio of 0.3667/0.49 = 0.7484, below the 0.8 threshold: a clear flag.
Check 2, run within tier, shows the gap does NOT fully close once qualification is controlled for: in the "mid" tier, group A hires at 43.9% versus group B at 31.05%; in the "high" tier, 75.36% versus 62.96%. Because the gap persists within tier, it is not simply explained by a genuine qualification difference, which is exactly the evidence legal would need to justify further investigation rather than closing the finding as "explained by qualifications."
Check 3 on the lending table shows, for example, the "600-649" band: group A's approved default rate is 34.55% versus group B's 18.69%, and the "650-699" band shows 21.43% versus 15.38%, both directions consistent with the model over-stating group B's risk relative to group A at the same nominal score band, a miscalibration-by-group finding distinct from (and complementary to) the hiring-side selection-rate finding.
Trade-offs and pitfalls
- The raw selection-rate ratio (check 1) is a necessary first screen but not sufficient on its own; a real qualification difference between groups can produce a ratio below 0.8 for entirely legitimate reasons, which is exactly why check 2 (within-tier) matters as a second, complementary check rather than a redundant one.
- SQL aggregate checks like these are populated by whatever the historical process already did; they can surface a disparity but cannot, on their own, tell you WHY it exists (a biased upstream screen, a genuinely predictive but disparate-impact-producing feature, or a real qualification gap), so the escalation to legal should be framed as "here is a flagged disparity and here is what further analysis would clarify it," not as a causal conclusion.
NULLIF(SUM(approved), 0)in check 3 avoids a divide-by-zero for a score band with zero approvals in a given group; a strata with very few approvals (a small group in a rare score band) needs the same small-sample caution as any other stratified fairness metric, since a rate computed on a handful of loans is noisy.- A common wrong turn for a data analyst is trying to "fix" the discovered disparity directly in a dashboard or a downstream report (adjusting numbers to look better) rather than escalating the raw, reproducible finding; the analyst's credibility and the finding's legal defensibility both depend on the escalation being an accurate, undoctored, well-documented signal.
Given an applications table with outcome, gender, race, score, and applied_at columns, write a SQL query to compute the disparate impact ratio (approval rate of a protected group divided by that of the reference group) per race and gender, flagging any group with a ratio below 0.8. State your assumptions about nulls and minimum sample size.
Sample Answer
Direct answer
Compute each group's approval rate, divide it by the highest approval rate observed among the groups being compared for that same protected attribute (the "80 percent rule" convention from the United States Equal Employment Opportunity Commission's Uniform Guidelines, which compares every group to whichever group fared best rather than to a hardcoded assumed-privileged group), and flag any ratio below 0.8. Two assumptions have to be stated explicitly before the numbers mean anything: rows with a NULL protected attribute must be excluded from that attribute's denominator rather than silently coerced into a group, and any group below a minimum sample size must be flagged as statistically unreliable rather than given a disparate impact ratio at all, since a tiny group's approval rate is too noisy to support a fairness conclusion either way.
Structured elaboration
Choosing the reference group. The 80 percent rule, as codified in the EEOC Uniform Guidelines on Employee Selection Procedures, defines the disparate impact ratio as a group's selection rate divided by the selection rate of the group with the HIGHEST selection rate among those being compared, not divided by an assumed majority or historically privileged group. This matters because hardcoding "male" or "white" as the denominator bakes in an assumption about which group is doing best that the data itself should determine, and it also means the reference group can legitimately be different for gender than for race, since they are separate comparisons over separate partitions of the same population.
NULL handling. A row with a NULL gender or NULL race cannot be assigned to any group, and it should not be silently dropped from the whole analysis, only from the specific cut (gender or race) where the value is missing; a row with a known race but missing gender should still count toward the race-based disparate impact calculation. Beyond just exclusion, the RATE of missingness itself is worth reporting separately: if protected-attribute data is missing disproportionately for one outcome or one time period, that is itself a data-quality finding that can distort every downstream ratio, and it should be surfaced, not silently absorbed into "excluded rows."
Minimum sample size. A group with a handful of applicants can show an extreme approval rate purely from noise: three approvals out of five applicants is a 60% rate that could easily have been 20% or 100% with one different outcome. Flagging a tiny group as a genuine disparate impact finding invites both false alarms (chasing noise) and false reassurance (a real disparity in a small group failing to clear an alarm threshold purely because there is not enough data to be confident either way). The practical fix is a minimum sample size threshold (commonly 30, informally tied to when a binomial proportion's normal approximation becomes reasonable, though a real analysis should also check a proper confidence interval such as Wilson or Clopper-Pearson rather than relying on the threshold alone) below which the query reports the group as having an insufficient sample rather than a computed ratio, so a "no flag" on a tiny group is never mistaken for a clean bill of health.
Query structure. Compute per-group counts and approval rates for gender and race as two separate partitions (a UNION ALL of two grouped aggregates, tagged by which attribute they belong to), take the maximum approval rate within each attribute's partition as that attribute's reference rate using a window function, then compute the ratio and the flag in one final pass.
Worked example
import sqlite3
import numpy as np
rng = np.random.default_rng(21)
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
cur.execute('''
CREATE TABLE applications (
id INTEGER PRIMARY KEY,
outcome INTEGER, -- 1 = approved, 0 = denied
gender TEXT,
race TEXT,
score REAL,
applied_at TEXT
)
''')
# Synthetic applicant pool with a deliberate, known disparity:
# - gender: 'male' approval rate ~0.55, 'female' ~0.40 (a real, measurable gap),
# plus a small 'nonbinary' group (n=18, below a minimum-sample threshold).
# - race: 'white' ~0.55, 'black' ~0.38, 'asian' ~0.56, plus a tiny 'native_american'
# group (n=12, also below the minimum-sample threshold).
# - a handful of rows have NULL gender/race, to exercise the null-handling rule.
rows = []
rid = 1
def add_group(n, gender, race, approval_rate):
global rid
for _ in range(n):
outcome = 1 if rng.uniform(0, 1) < approval_rate else 0
score = rng.normal(650, 50)
rows.append((rid, outcome, gender, race, round(float(score), 1), "2026-01-15"))
rid += 1
add_group(1200, "male", "white", 0.58)
add_group(1100, "female", "white", 0.42)
add_group(500, "male", "black", 0.40)
add_group(480, "female", "black", 0.36)
add_group(400, "male", "asian", 0.60)
add_group(380, "female", "asian", 0.54)
add_group(18, "nonbinary", "white", 0.50) # below minimum sample size for gender x this cut
add_group(12, "male", "native_american", 0.45) # below minimum sample size for race
add_group(40, None, "white", 0.50) # NULL gender: excluded from the gender cut
add_group(35, "female", None, 0.45) # NULL race: excluded from the race cut
cur.executemany("INSERT INTO applications VALUES (?, ?, ?, ?, ?, ?)", rows)
conn.commit()
MIN_SAMPLE = 30
query = f'''
WITH group_rates AS (
SELECT 'gender' AS attribute, gender AS group_value,
COUNT(*) AS n,
SUM(CASE WHEN outcome = 1 THEN 1 ELSE 0 END) AS approvals,
AVG(CASE WHEN outcome = 1 THEN 1.0 ELSE 0.0 END) AS approval_rate
FROM applications
WHERE gender IS NOT NULL
GROUP BY gender
UNION ALL
SELECT 'race' AS attribute, race AS group_value,
COUNT(*) AS n,
SUM(CASE WHEN outcome = 1 THEN 1 ELSE 0 END) AS approvals,
AVG(CASE WHEN outcome = 1 THEN 1.0 ELSE 0.0 END) AS approval_rate
FROM applications
WHERE race IS NOT NULL
GROUP BY race
),
with_reference AS (
SELECT *,
MAX(approval_rate) OVER (PARTITION BY attribute) AS reference_rate
FROM group_rates
)
SELECT
attribute,
group_value,
n,
approvals,
ROUND(approval_rate, 4) AS approval_rate,
ROUND(reference_rate, 4) AS reference_rate,
CASE WHEN n >= {MIN_SAMPLE}
THEN ROUND(approval_rate / reference_rate, 4)
ELSE NULL
END AS disparate_impact_ratio,
CASE
WHEN n < {MIN_SAMPLE} THEN 'INSUFFICIENT_SAMPLE'
WHEN approval_rate / reference_rate < 0.8 THEN 'FLAGGED'
ELSE 'OK'
END AS flag
FROM with_reference
ORDER BY attribute, disparate_impact_ratio;
'''
cur.execute(query)
cols = [d[0] for d in cur.description]
print(" | ".join(f"{c:>20}" for c in cols))
for row in cur.fetchall():
print(" | ".join(f"{str(v):>20}" for v in row))
# Sanity checks: confirm the null rows were excluded from both cuts.
cur.execute("SELECT COUNT(*) FROM applications WHERE gender IS NULL")
print("\nrows with NULL gender (excluded from the gender cut):", cur.fetchone()[0])
cur.execute("SELECT COUNT(*) FROM applications WHERE race IS NULL")
print("rows with NULL race (excluded from the race cut):", cur.fetchone()[0])
cur.execute("SELECT COUNT(*) FROM applications")
print("total rows in applications:", cur.fetchone()[0])
Executed output:
attribute | group_value | n | approvals | approval_rate | reference_rate | disparate_impact_ratio | flag
gender | nonbinary | 18 | 6 | 0.3333 | 0.5294 | None | INSUFFICIENT_SAMPLE
gender | female | 1995 | 844 | 0.4231 | 0.5294 | 0.7992 | FLAGGED
gender | male | 2112 | 1118 | 0.5294 | 0.5294 | 1.0 | OK
race | native_american | 12 | 4 | 0.3333 | 0.5551 | None | INSUFFICIENT_SAMPLE
race | black | 980 | 389 | 0.3969 | 0.5551 | 0.715 | FLAGGED
race | white | 2358 | 1143 | 0.4847 | 0.5551 | 0.8732 | OK
race | asian | 780 | 433 | 0.5551 | 0.5551 | 1.0 | OK
rows with NULL gender (excluded from the gender cut): 40
rows with NULL race (excluded from the race cut): 35
total rows in applications: 4165
The male group (approval rate 0.5294) is automatically the gender reference, since it has the highest rate, without that having been hardcoded anywhere in the query; female's ratio comes out to 0.7992, just under the 0.8 line, so it is correctly FLAGGED, and this is close enough to the threshold to illustrate why the exact reference-rate computation matters, a slightly different reference group choice could have pushed this either side of 0.8. On race, asian is the reference (0.5551), black is clearly flagged at 0.715, and white lands at 0.8732, above the line despite also being below the reference rate, showing the ratio, not just "is this group below the top group," is what the rule actually tests. Both the nonbinary gender group (n=18) and the native_american race group (n=12) are correctly reported as INSUFFICIENT_SAMPLE with a NULL ratio rather than a computed number, even though their raw approval rates (0.3333 for both) look dramatically low, which is exactly the case this safeguard exists for: a rate that looks alarming from 12 or 18 people is not yet evidence of anything. The 40 NULL-gender rows and 35 NULL-race rows are confirmed excluded from their respective cuts, and the total row count (4165) confirms nothing was silently dropped from the table itself, only from the specific aggregate where the attribute was missing.
Trade-offs and pitfalls
The most common mistake is hardcoding a single "majority" group as the denominator for every comparison rather than deriving the reference rate from the data, which silently changes the definition of the metric and can produce a different flag decision than the standard 80 percent rule would; if a business specifically wants a fixed historical reference group instead of the highest-rate group (sometimes required by a specific regulatory context), that choice should be an explicit, named parameter in the query, not an implicit accident of column ordering. A second pitfall is applying the 0.8 threshold to a group with a tiny sample without a floor, which either buries a real disparity in "not enough data to say" or manufactures a false alarm from three unlucky outcomes; the minimum-sample gate above is a coarse first line of defense, and a more rigorous version would attach a confidence interval to each group's rate and consider a flag confirmed only when the interval clearly excludes 0.8, not just when the point estimate does. A third is treating a passing disparate impact ratio as proof of no discrimination: the 80 percent rule is a screening heuristic for disparate IMPACT (an aggregate outcome pattern), not a test for disparate TREATMENT (a demonstrated intent or the use of a protected attribute or an obvious proxy for it directly in the decision process), and both are legally and practically distinct questions that this single query answers only the first of. Finally, running this query as a one-time report rather than a monitored metric misses the point: a ratio near but above 0.8 today, like female's 0.7992 here sitting a hair below it, or white's 0.8732 sitting closer to the line than the other passing groups, is a candidate for ongoing tracking, since a small shift in the underlying approval process could tip it over the threshold in either direction next period.
Design a fairness and bias evaluation plan for a loan-approval or hiring model that shows performance disparities across demographic subgroups. Include which metrics you would compute, how you would choose the sensitive attributes, how you would trade off fairness against business objectives, and a decision framework for remediation.
Sample Answer
Direct answer
A fairness evaluation plan for a loan-approval or hiring model needs at least four DISTINCT metric families, demographic parity, disparate-impact ratio, equal opportunity together with its equalized-odds companion check (the matching false-positive-rate gap), and calibration-within-groups, computed together, because they answer different questions and a model can pass one while badly failing another. Choosing the sensitive attribute means starting from the model's actual legally or organizationally protected categories for its use case (not an arbitrary convenient grouping), and the remediation decision framework routes based on WHICH metric failed: a demographic-parity or disparate-impact failure with equal calibration points at the decision threshold or business process, while a calibration failure points at the scoring function itself needing retraining, so the trade-off against business objectives is not one blanket negotiation but a different, metric-specific conversation each time.
Structured elaboration
The four metrics and what each one actually checks.
- Demographic parity: the overall approval-rate gap between groups. Answers "are groups being approved at similar rates," independent of whether that rate SHOULD be similar given real qualification differences; a useful first check but insufficient alone, since equal approval rates could mask unequal accuracy.
- Disparate-impact ratio: the ratio (lower group rate over higher group rate), the standard compliance-oriented framing of the same underlying quantity as demographic parity, with an external four-fifths-rule benchmark many organizations also compare against.
- Equal opportunity (with its equalized-odds companion check): the true-positive-rate (recall among ACTUALLY qualified applicants) gap between groups. Answers "among people who deserve approval, are they equally likely to get it," which is a fundamentally different and often more decision-relevant question than raw approval-rate parity. Equal opportunity by itself only requires the TRUE-positive side to match across groups; the fuller equalized-odds standard also requires the FALSE-positive rate (the share of NOT-actually-qualified applicants who get approved anyway) to match, so the plan computes the TPR gap and the FPR gap side by side rather than treating equal opportunity alone as the complete picture.
- Calibration within groups: whether a given score means the same real-world probability of the outcome across groups. Answers "does a 0.5 score mean the same thing for everyone," which a model can violate badly even while looking fine on the first three metrics.
Choosing sensitive attributes. Start from the categories with actual legal protection or organizational policy coverage for the specific use case (which differ between employment and credit contexts), not from whichever demographic field happens to be easiest to query; where a directly protected attribute is not collected (common for privacy reasons), use a documented, validated proxy methodology and explicitly caveat any metric computed on a proxy as an ESTIMATE with its own uncertainty, not a exact measurement.
Trading off fairness against business objectives. This is not one negotiation but a different one per metric, because the FIX differs: a demographic-parity/disparate-impact gap with equal calibration and equal opportunity is often a threshold or process issue (the cheapest class of fix, usually preserving most of the model's business value); an equal-opportunity gap with good calibration points at needing a different decision rule per group or an in-processing fairness constraint during training (a real accuracy cost, but usually smaller than expected if the current gap stems from an avoidable modeling artifact rather than a genuine trade-off); a calibration gap is the most serious, since it means the SCORE ITSELF is unreliable for one group, and no downstream threshold choice can fix that without addressing the scoring function.
Remediation decision framework, in order of investigation: check calibration first (if scores don't mean the same thing across groups, nothing else can be trusted at face value); then check equal opportunity (a real gap here, with good calibration, indicates a genuine accuracy trade-off is being made, deliberately or not); then check demographic parity/disparate impact (often the easiest to move without an accuracy cost, since a threshold or scoring shift can correct it directly once the more fundamental calibration and equal-opportunity checks are clean).
Closing the loop: legal/product engagement and ongoing monitoring. A remediation decision is not complete once a fix is chosen; for a credit or hiring use case specifically, the finding and the chosen fix should be reviewed with legal (who can assess whether the pre-fix gap created any notification or documentation obligation, independent of engineering's remediation timeline) and with the product owner (who needs to sign off on any accuracy trade-off before it ships, since a fairness fix that changes approval or hiring outcomes is a product decision, not a purely technical one). After the fix ships, the same four-metric evaluation should move from a one-time audit into standing production monitoring with its own documentation trail (a dated record of the finding, the chosen fix, and the post-fix re-measurement), so a later audit or regulator inquiry can see the full history rather than only the current, already-fixed state.
Worked example
All four metrics computed on a loan-approval scenario where the two groups' TRUE creditworthy base rate is nearly equal, so any measured gap reflects the model, not a real underlying difference:
import numpy as np
rng = np.random.default_rng(2026)
n_a, n_b = 6000, 2000
true_a = rng.binomial(1, 0.55, n_a)
true_b = rng.binomial(1, 0.55, n_b)
score_a = np.where(true_a==1, rng.normal(0.70,0.15,n_a), rng.normal(0.30,0.15,n_a))
score_b = np.where(true_b==1, rng.normal(0.58,0.15,n_b), rng.normal(0.30,0.15,n_b))
score_a, score_b = np.clip(score_a,0,1), np.clip(score_b,0,1)
threshold = 0.5
approve_a, approve_b = (score_a>=threshold).astype(int), (score_b>=threshold).astype(int)
dp_a, dp_b = approve_a.mean(), approve_b.mean()
di_ratio = min(dp_a,dp_b)/max(dp_a,dp_b)
tpr_a = approve_a[true_a==1].mean()
tpr_b = approve_b[true_b==1].mean()
fpr_a = approve_a[true_a==0].mean()
fpr_b = approve_b[true_b==0].mean()
band_a = (score_a>=0.45)&(score_a<0.55)
band_b = (score_b>=0.45)&(score_b<0.55)
calib_a, calib_b = true_a[band_a].mean(), true_b[band_b].mean()
print("demographic parity:", dp_a, dp_b, "gap", dp_a-dp_b, "DI ratio", di_ratio)
print("equal opportunity (TPR):", tpr_a, tpr_b, "gap", tpr_a-tpr_b)
print("equalized odds (FPR):", fpr_a, fpr_b, "gap", abs(fpr_a-fpr_b))
print("calibration @0.5 band:", calib_a, calib_b, "gap", abs(calib_a-calib_b))
print("true base rates:", true_a.mean(), true_b.mean())
Executed output (this is the literal stdout of the code block above, run as one fresh module in a clean interpreter -- nothing here was typed by hand):
demographic parity: 0.5268333333333334 0.436 gap 0.09083333333333338 DI ratio 0.8275862068965516
equal opportunity (TPR): 0.8995052566481138 0.7168141592920354 gap 0.18269109735607836
equalized odds (FPR): 0.0911062906724512 0.07126436781609195 gap 0.019841922856359245
calibration @0.5 band: 0.5525179856115108 0.75 gap 0.19748201438848922
true base rates: 0.539 0.565
Reading the four printed lines in the decision framework's own order: (1) demographic parity shows a 9.08pp approval-rate gap, and the disparate-impact ratio of 0.8276 technically passes the common four-fifths external benchmark; (2) equal opportunity fails badly, an 18.27pp TPR gap (group A's actually-creditworthy applicants are approved 89.95% of the time, group B's only 71.68%); its equalized-odds companion, the FPR gap, is comparatively small at 1.98pp (FPR_A=9.11%, FPR_B=7.13%), meaning the score compression for group B mostly costs creditworthy applicants who get wrongly denied, not a meaningful change in how often NOT-actually-creditworthy applicants get wrongly approved -- the TPR side of equalized odds is where this model's real problem lives, not the FPR side; (3) calibration fails worst of all, a 19.75pp gap: the same 0.5 score means roughly a 55% real repayment probability for group A but 75% for group B, and because that is checked FIRST in the decision framework, it is the most actionable finding, since it means the score itself, not the threshold, is the problem. Taken together, the underlying model has two seriously broken metrics (calibration and equal opportunity) sitting behind a disparate-impact ratio that alone would have looked acceptable, which is exactly why relying on disparate-impact alone as the sole compliance check would have missed the real issue here. Because the true base rates are nearly equal (0.5390 vs 0.5650), none of this is a case of the Kleinberg/Chouldechova impossibility result forcing an unavoidable trade-off between calibration and equalized odds; it is an ordinary, fixable miscalibration in how group B's score is computed, not a fundamental trade-off to accept.
Trade-offs and pitfalls
The most damaging mistake is computing only demographic parity or disparate impact (the metric with the most familiar external compliance benchmark) and stopping there, since the worked example shows a model can pass the four-fifths rule while having a severe calibration failure that a disparate-impact-only audit would never surface; the plan needs all four metric families run together, every time, not a single headline number. A second pitfall is invoking the Kleinberg/Chouldechova impossibility result reflexively whenever two fairness metrics conflict, without checking whether the groups' true base rates actually differ; as shown here, when base rates are equal, a measured conflict between calibration and equal opportunity is a fixable model defect, not a forced mathematical trade-off, and treating it as unavoidable would mean shipping a genuinely broken scoring function under the cover of "this is just the fairness-metrics impossibility, nothing to be done." A third pitfall is trading off fairness against business objectives as one undifferentiated negotiation; as the remediation framework argues, a demographic-parity gap is often cheap to fix (threshold-level) while a calibration gap requires retraining, so presenting both to a business stakeholder as equally costly interventions either overstates the cost of the easy fix or understates the cost of the hard one. Finally, when the sensitive attribute must be estimated via a proxy rather than directly observed, every one of these four metrics inherits the proxy's own uncertainty, and reporting a precise-looking gap ("9.08 percentage points") without flagging that the underlying group labels are themselves estimates overstates the finding's precision to whoever reads the report next.
Define the disparate impact ratio and the 80 percent rule used in US employment-law contexts. Show how to compute the ratio from a model's predictions, discuss the limitations of the 80 percent rule, and explain when you would prefer a ratio-based test over a difference-based fairness test.
Sample Answer
Direct answer: the disparate impact ratio compares the selection rate of a protected group to that of the most-favored group; the 80 percent rule (from the EEOC's Uniform Guidelines on Employee Selection Procedures) treats a ratio below 0.8 as evidence of possible discrimination that shifts the burden to the employer to justify the practice.
Structured elaboration. Formally, DI ratio=selection rate of most-favored groupselection rate of protected group. It is a RATIO test, unlike demographic parity's DIFFERENCE test, which matters because a difference of a few points can look small in absolute terms but represent a large relative disadvantage when base selection rates are low.
Worked example (executed).
group_A_selected, group_A_total = 48, 200 # 24.0% selection rate
group_B_selected, group_B_total = 90, 300 # 30.0% selection rate
rate_A = group_A_selected / group_A_total
rate_B = group_B_selected / group_B_total
ratio = min(rate_A, rate_B) / max(rate_A, rate_B)
print(f"rate_A = {rate_A:.3f}, rate_B = {rate_B:.3f}, ratio = {ratio:.3f}")
Output (literal stdout of the code above, run fresh): rate_A = 0.240, rate_B = 0.300, ratio = 0.800 (exactly 80%). This example sits precisely on the regulatory threshold: a small additional shortfall for group A (say 47 selected instead of 48) would drop the ratio below 0.8 and trigger scrutiny under the guideline.
Trade-offs and pitfalls. (1) The 80% rule is a rule of thumb from 1978 guidance, not a statistical significance test; a small sample can swing the ratio a lot, so courts and regulators also look at statistical significance (commonly a z-test on the rate difference) alongside the ratio. (2) The ratio direction matters: always divide the SMALLER rate by the LARGER rate, never the reverse, or you will get a number above 1 and miss a real disparity. (3) Prefer the ratio test when absolute selection rates are low (a 2-point difference at 5% vs 7% is a much bigger relative gap than the same 2-point difference at 45% vs 47%); prefer a difference-based test like demographic parity difference when you specifically care about the absolute number of people affected, since a 0.79 ratio at very high volume can represent thousands of affected people while the same ratio at low volume affects a handful.
Define demographic parity, equalized odds, and calibration (group-wise calibration). For each metric give a formal definition and a loan-approval example of how you would measure it, then state which metric you would prioritize if (a) a regulator requires equal treatment across groups and (b) downstream decisions require well-calibrated risk scores.
Sample Answer
A strong answer opens by naming the three definitions and stating plainly that they generally cannot all hold at once when base rates differ across groups.
Structured elaboration
| Metric | Formal condition | What it controls |
|---|---|---|
| Demographic parity | P(Y^=1∣A=a)=P(Y^=1∣A=b) | Equal selection rate across groups, regardless of outcome |
| Equalized odds | P(Y^=1∣Y=y,A=a)=P(Y^=1∣Y=y,A=b) for both y∈{0,1} | Equal true-positive and false-positive rates across groups |
| Calibration (group-wise) | P(Y=1∣score=s,A=a)=s for every group a | A predicted score of s means the same real-world probability in every group |
Loan example. Say a bank approves loans with a risk score.
- Demographic parity means the same fraction of applicants in each demographic group gets approved, even if the groups have different true default rates.
- Equalized odds means that among applicants who would actually repay, the approval rate is the same across groups (equal TPR), and among those who would default, the rejection rate is the same across groups (equal FPR).
- Calibration means that a 0.2 default-risk score means a genuine 20% default probability whether the applicant is in group A or group B.
Worked example. If group A has a true default rate of 10% and group B has a true default rate of 30%, a single calibrated score function will naturally assign more high scores to group B. Forcing demographic parity on top of that calibration would require either denying good group-A applicants or approving bad group-B applicants purely to match rates, which breaks calibration. This is not a hypothetical: it is the mathematical content of the impossibility result once you fix differing base rates.
Trade-offs and pitfalls. (a) A regulator asking for "equal treatment across groups" usually means demographic parity or equalized odds, not calibration, so lean there. (b) A downstream risk-scoring use case (setting an interest rate, sizing a reserve) needs calibration, because a wrongly-calibrated score misprices risk for an entire group even if selection rates look fair. (c) The most common mistake is treating these three as compatible variations on "fairness" rather than as genuinely conflicting design choices; picking one is a policy decision, not a purely technical one, and should be made with legal and business stakeholders, not unilaterally by the model team.
Unlock Full Question Bank
Get access to all 15 Responsible AI: Fairness, Bias, and Interpretability interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.