Knowledge / Artificial Intelligence and Data Science / AI ethics, bias and responsible AI

AI ethics, bias and responsible AI

Artificial Intelligence and Data Science (B.E./B.Tech) · Data engineering and deployment · free study notes for exams, placements and interviews

In short

AI ethics is the study of what an automated decision system ought and ought not do; bias is the measurable part of it — a model that is systematically less accurate or less favourable for one group of people than another. Responsible AI is the engineering practice that makes ethics operational: documented data, measured fairness, explainable predictions, privacy protection, human oversight and audit trails built into the pipeline rather than bolted on. It matters because AI/DS graduates in India now build credit-scoring, hiring-shortlist, insurance-pricing, fraud and welfare-eligibility models where a biased output has legal and human consequences under the DPDP Act, 2023, RBI and SEBI supervisory expectations and NITI Aayog's Responsible AI principles. It is examined in AICTE AI&DS electives ("Ethics in AI", "Responsible AI"), in UGC CBCS data-science papers, and asked in placement rounds at TCS, Infosys, Wipro, Accenture, Fractal, Mu Sigma, ZS, Swiggy, Razorpay, HDFC and every bank's analytics unit. Expect numerical questions on fairness metrics computed from confusion matrices — that is the most examinable part of the topic.

Explained

What "bias" means, and the five places it enters

Fairness definitions (and why you cannot have them all)

Let A = protected attribute (group), Y = true label, Ŷ = prediction, S = score.

Responsible AI principles and the Indian framework

How bias is found: the measurement workflow

  1. Define the decision and the harm — allocative (who gets the loan) or representational (who is depicted how). Name the groups and get legal sign-off on using the protected attribute for *testing*.
  2. Document the data — Datasheets for Datasets: provenance, collection method, consent basis, population covered, known gaps, time window.
  3. Slice the metrics — never report one aggregate number. Build a per-group confusion matrix and compute accuracy, TPR, FPR, PPV, selection rate.
  4. Disaggregated and intersectional evaluation — test A alone, B alone and A∩B. Gender Shades (Buolamwini and Gebru, 2018) found commercial gender classifiers erred ~0.8% on lighter males and up to ~34.7% on darker females; neither single axis exposed that.
  5. Test with a gap threshold agreed in advance (e.g. TPR gap ≤ 5 pp, disparate impact ≥ 0.8) so the result is not negotiated after the fact.
  6. Monitor post-deployment — drift in data and in the fairness gap, complaint/appeal rates per group, override rates by human reviewers.
  7. Tools: IBM AI Fairness 360, Microsoft Fairlearn, Google What-If Tool, Aequitas, fairlearn.metrics.MetricFrame.

How bias is reduced: three families of mitigation

Transparency, explainability and accountability

Key points

Formulas and examples

Per-group confusion matrix: TP, FP, FN, TN for each group a of the protected attribute A
TPR (recall, sensitivity) = TP / (TP + FN); FPR = FP / (FP + TN); FNR = 1 − TPR
Precision (PPV) = TP / (TP + FP); Accuracy = (TP + TN) / N
Selection rate SR(a) = (TP + FP) / N(a) — share of group a receiving the positive decision
Statistical parity difference SPD = SR(a=unprivileged) − SR(a=privileged) (ideal 0; units: proportion or pp)
Disparate impact ratio DI = SR(unprivileged) / SR(privileged) (ideal 1; red flag < 0.8)
Equal opportunity difference EOD = TPR(unpriv) − TPR(priv) (ideal 0)
Average odds difference AOD = ½ [ (FPR_unpriv − FPR_priv) + (TPR_unpriv − TPR_priv) ]
Theil index (individual-level inequality) T = (1/n) Σ (bᵢ/μ) ln(bᵢ/μ), where bᵢ = Ŷᵢ − Yᵢ + 1 and μ = mean of bᵢ
Differential privacy: Pr[M(D) ∈ S] ≤ eε · Pr[M(D′) ∈ S] for datasets differing in one record; ε in nats, δ = failure probability
Shapley value φᵢ = Σ_{S ⊆ F\{i}} [ |S|!(|F|−|S|−1)! / |F|! ] · [ f(S ∪ {i}) − f(S) ]; Σφᵢ = f(x) − E[f(X)]

Example 1 — selection rate, SPD and disparate impact in campus shortlisting. A screening model is run on 1,000 applicants from Tier-1 colleges and 1,000 from Tier-2/3 colleges. It shortlists 400 Tier-1 and 240 Tier-2/3.

Example 2 — equal opportunity and equalised odds from confusion matrices. A loan default-risk model (positive = "approve"), two groups, 1,000 applicants each.

MetricGroup PGroup U
TP420180
FP8060
FN180220
TN320540
Total10001000

Example 3 — post-processing with group thresholds. On group U, lowering the score threshold moves 60 applicants from the predicted-negative side into approval; of them 48 are true positives and 12 are false positives.

Example 4 — intersectional accuracy, aggregate vs worst group. A face-attribute model is tested on 10,000 images with per-subgroup error rates:

SubgroupnError rateErrors
Lighter male4,0001.0%40
Lighter female3,0003.0%90
Darker male2,0006.0%120
Darker female1,00030.0%300
Total10,000—550

Example 5 — differential privacy budget. A query answered with the Laplace mechanism on a count (sensitivity Δf = 1) at ε = 0.5 uses noise scale b = Δf/ε = 1/0.5 = 2, giving standard deviation √2·b ≈ 2.83 counts.

from fairlearn.metrics import MetricFrame, selection_rate, true_positive_rate
mf = MetricFrame(metrics={"sel": selection_rate, "tpr": true_positive_rate},
                 y_true=y_test, y_pred=y_pred, sensitive_features=group)
print(mf.by_group)          # per-group table
print(mf.difference())      # largest gap
print(mf.ratio())           # disparate impact style ratio
Fairness notionEqualiseUse whenWeakness
Demographic paritySelection rateRepresentation targets, outreachIgnores real base-rate differences
Equal opportunityTPRBenefit decisions (loan, screening)Silent on false positives
Equalised oddsTPR and FPRPunitive decisions (fraud, risk)Breaks calibration
Predictive parityPrecisionVendor/score defenceAllows large FPR gaps
CalibrationP(Y=1S=s)Risk scores shown to humansIncompatible with equal odds
Counterfactual fairnessCausal effect of ALegal/causal reasoningNeeds a causal graph

Where it is used

Interview questions

Common mistakes

Related topics

MLOps and model deployment · AI regulation and governance · Data pipelines: Airflow and Kafka · Data warehousing and ETL · Explainable AI and model interpretability · Machine learning evaluation metrics

Open in the Knowledge reader →Find jobs →