AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

AI Bias and Fairness: Building Ethical AI Systems

📚 Ethics & Society⏱️ 27 min read🎓 Grade 10
✍️ AI Computer Institute Editorial Team Updated: September 2026 CBSE-aligned · Peer-reviewed · 27 min read
Content curated by subject matter experts with IIT/NIT backgrounds. All chapters are fact-checked against official CBSE/NCERT syllabi.

The Loan That Took Three Seconds to Reject

Rohan runs a small tiffin service out of his home in Pune, cooking and delivering home-style lunches to about forty regular customers within a three-kilometre radius. Business is good enough that he wants to buy a second scooter and bring on a helper, so he opens a lending app that promises "instant AI-approved personal loans in under a minute." He fills in his details, links his UPI transaction history as proof of steady income, and waits. Three seconds later: rejected, "insufficient creditworthiness score." No further explanation. His friend Priya, who earns roughly the same monthly income and whose repayment history is no stronger than his, applies for a similar loan amount from her apartment across town and is approved instantly.

Neither of them is told why. The decision came from a machine learning model trained on thousands of past loan records, and somewhere in that training data the model learned a pattern that has nothing to do with Rohan's actual ability to repay a loan, and everything to do with people who share his postal code. This is not a hypothetical worry invented for a textbook. It is a well-documented risk in modern algorithmic lending, and understanding exactly how and why it happens — and what can be done about it — is what this chapter is about.

What Do We Mean by "Bias"?

The word bias starts its life in statistics, where it has a precise, morally neutral meaning: the systematic deviation of a measurement or estimate from the true value, as opposed to random error. A weighing scale that always reads two kilograms heavy is biased — every single measurement is wrong in the same direction. A scale that sometimes reads high and sometimes reads low, averaging out to the correct value, is noisy but not biased.

In AI ethics, the word carries this same idea of "systematically wrong in one direction," but applied to people instead of measurements. Here, bias means an AI system's outputs are systematically less favourable for some group of people, based on characteristics that should not have determined the outcome — gender, religion, caste, region, disability, or economic background. These are often called protected attributes.

Machine learning models are, at their core, pattern-matching machines. They are trained on historical data, and they learn to reproduce whatever statistical regularities exist in that data — full stop. A model has no built-in sense of justice that tells it "this pattern reflects unfair discrimination, ignore it" versus "this pattern reflects a genuine, fair signal, keep it." If the historical data was generated by a world with unequal access to credit, education, or employment, the model will faithfully learn those inequalities as if they were neutral facts about the world, because from a purely statistical standpoint, they are facts about the world — just not fair ones to act on.

A crucial and often misunderstood point: a model does not need to be handed someone's caste, religion, or gender to discriminate on that basis. It only needs a proxy variable — a feature that correlates strongly enough with a protected attribute to stand in for it. Postal code, surname, the school someone attended, and even specific word choices on a resume can all function as accidental proxies. Simply deleting the sensitive column from the dataset before training — an approach sometimes called fairness through unawareness — does not fix this, because the correlated information is still smuggled in through every proxy left behind. If Rohan's locality is disproportionately home to a particular religious or economic community, using his postal code as a lending feature can reconstruct exactly the discrimination the developers thought they had removed.

How Bias Enters an AI System

Bias does not appear from nowhere; it enters an AI system at specific, identifiable points along the pipeline that takes raw data and turns it into a decision. Four patterns show up again and again.

  • Historical bias is when the training data accurately reflects a world that was already unequal, so the model learns to continue that inequality. Amazon's internal AI recruiting tool is the textbook case. Starting in 2014, Amazon's engineers built a system that scored job applicants from one to five stars, the same way products are rated on Amazon's shopping site. It was trained by studying resumes submitted to the company over the previous ten years, and because the tech industry's applicant pool had been overwhelmingly male throughout that period, the model concluded that male candidates were simply better. By 2015, Amazon's own team noticed the tool was not rating candidates for technical roles in a gender-neutral way: it penalized resumes containing the word "women's" — as in "women's chess club captain" or the name of an all-women's college — and rewarded language more typical of men's resumes. Amazon edited the program to stop weighting those specific terms, but by early 2017 abandoned the project entirely, unable to guarantee it hadn't found other, subtler ways to discriminate on gender.
  • Representation bias is when the training data simply does not contain enough examples of some group for the model to learn that group well. In 2018, researchers Joy Buolamwini and Timnit Gebru built a face dataset balanced across gender and skin tone and used it to test three commercial facial-analysis systems, from IBM, Microsoft, and Face++. All three had been trained largely on datasets dominated by lighter-skinned faces. The result: error rates for darker-skinned women reached as high as 34.7 percent, while the worst error rate recorded for lighter-skinned men, across all three systems, was just 0.8 percent. The systems hadn't seen enough of the underrepresented group to learn it properly.
  • Measurement bias happens when a feature used to train the model is a flawed stand-in for the thing it's actually trying to measure — exactly the postal-code problem in Rohan's case. A lending app might use location as a rough proxy for financial stability, because on average it correlates with income. But within Rohan's own locality there is enormous variation in individual creditworthiness, and using the locality-level average punishes every individual who doesn't fit that average, including people who are demonstrably better credit risks than their more "premium" neighbours.
  • Feedback loop bias occurs when a model's own predictions shape the future data it gets retrained on. A predictive-policing system that flags a neighbourhood as high-risk causes more patrols to be sent there; more patrols record more minor infractions; those infraction records feed back into the training data as "confirmed high crime," which raises the neighbourhood's risk score further next time — regardless of whether its underlying crime rate was ever actually higher than anywhere else.

Rohan's rejection most plausibly falls into the third category: a proxy variable doing statistical damage that a fairer feature set would have avoided. To see exactly how a pattern like this can be measured, and how easy it is to miss if you're only looking at one aggregate number, it helps to work through it with real arithmetic.

Measuring Fairness: A Worked Example

Consider a simplified, entirely constructed version of Rohan's situation, built purely to illustrate the mechanics — not real data from any real bank. Suppose a lender's model has been evaluated on 200 past applicants, 100 from Locality A (where Rohan lives) and 100 from Locality B (a wealthier locality across town). To check for bias, it is not enough to look at the model's overall accuracy across all 200 people. The check has to be done separately for each group, using a confusion matrix: a table that cross-tabulates what actually happened against what the model predicted.

For a loan decision, there are four possible outcomes: a True Positive (TP) is someone who would genuinely have repaid and was correctly approved; a False Negative (FN) is someone who would genuinely have repaid but was wrongly rejected; a False Positive (FP) is someone who would have defaulted but was wrongly approved anyway; and a True Negative (TN) is someone who would have defaulted and was correctly rejected.

Now suppose that, in truth, exactly 60 of the 100 applicants in each locality are genuinely creditworthy and 40 are not — the same underlying qualification rate in both groups, deliberately, so that any gap we find in the model's behaviour can't be blamed on one locality actually being riskier than the other. The model produces these decisions:

Locality A — 100 applicants (60 genuinely creditworthy, 40 not)
                        Predicted: Approve   Predicted: Reject
  Actually repays              TP = 42              FN = 18
  Actually defaults            FP = 8               TN = 32

Locality B — 100 applicants (60 genuinely creditworthy, 40 not)
                        Predicted: Approve   Predicted: Reject
  Actually repays              TP = 54              FN = 6
  Actually defaults            FP = 8               TN = 32

From these two tables, three standard metrics can be calculated by hand. The True Positive Rate (TPR), also called recall or sensitivity, answers: of everyone who genuinely deserved the loan, what fraction actually got approved? It is TP divided by (TP + FN).

  • Locality A: 42 / (42 + 18) = 42 / 60 = 0.70, or 70 percent.
  • Locality B: 54 / (54 + 6) = 54 / 60 = 0.90, or 90 percent.

The False Positive Rate (FPR) answers: of everyone who genuinely would have defaulted, what fraction did the model mistakenly approve anyway? It is FP divided by (FP + TN).

  • Locality A: 8 / (8 + 32) = 8 / 40 = 0.20, or 20 percent.
  • Locality B: 8 / (8 + 32) = 8 / 40 = 0.20, or 20 percent — identical.

And the overall approval rate — (TP + FP) divided by 100 — is 50 percent for Locality A and 62 percent for Locality B.

Now combine both localities and check the number a bank manager glancing at a dashboard would actually see: overall accuracy across all 200 applicants. Total correct decisions are (42 + 54) true positives plus (32 + 32) true negatives, which is 96 + 64 = 160 out of 200, or 80 percent. An 80 percent accuracy figure looks perfectly respectable, and a bank that only checks this one aggregate number would see nothing wrong. But look at what that single number is hiding: the model's risk-control behaviour is identical in both localities — it lets through exactly 20 percent of the applicants who would have defaulted, either way, so it isn't simply "more cautious" toward Locality A. Yet a genuinely creditworthy applicant in Locality A had only a 70 percent chance of being correctly approved, against 90 percent in Locality B. Flip that around: 30 percent of qualified Locality A applicants were wrongly turned away, compared with just 10 percent in Locality B — a qualified applicant like Rohan was three times as likely to be wrongly denied a loan he genuinely deserved, purely because of where he lives. That gap is invisible in the headline accuracy figure and only shows up once the confusion matrix is broken down by group.

Tracing the Fairness Check in Code

The same calculation can be automated, which matters in practice because real evaluation sets have thousands of applicants, not 100. Here is a compact Python implementation that reproduces the hand calculation above exactly:

# 1 = genuinely creditworthy (would repay), 0 = would default
group_a_actual    = [1] * 60 + [0] * 40
group_a_predicted = [1] * 42 + [0] * 18 + [1] * 8 + [0] * 32

group_b_actual    = [1] * 60 + [0] * 40
group_b_predicted = [1] * 54 + [0] * 6 + [1] * 8 + [0] * 32

def confusion_counts(actual, predicted):
    tp = sum(1 for a, p in zip(actual, predicted) if a == 1 and p == 1)
    fn = sum(1 for a, p in zip(actual, predicted) if a == 1 and p == 0)
    fp = sum(1 for a, p in zip(actual, predicted) if a == 0 and p == 1)
    tn = sum(1 for a, p in zip(actual, predicted) if a == 0 and p == 0)
    return tp, fn, fp, tn

def fairness_report(name, actual, predicted):
    tp, fn, fp, tn = confusion_counts(actual, predicted)
    tpr = tp / (tp + fn)
    fpr = fp / (fp + tn)
    approval_rate = (tp + fp) / len(actual)
    print(f"{name}: TPR={tpr:.2f}  FPR={fpr:.2f}  Approval rate={approval_rate:.2f}")

fairness_report("Locality A", group_a_actual, group_a_predicted)
fairness_report("Locality B", group_b_actual, group_b_predicted)

Trace through what actually happens when this runs. group_a_actual is a list of 100 numbers: index 0 through 59 hold a 1, index 60 through 99 hold a 0 — that's the 60 genuinely creditworthy applicants followed by the 40 who are not. group_a_predicted is built to line up with it in four blocks: index 0–41 are 1 (the model approved these, and since the actual value there is also 1, each pairing is a true positive — 42 of them), index 42–59 are 0 (actual is still 1 here, so each pairing is a false negative — 18 of them), index 60–67 are 1 (actual is now 0, so each pairing is a false positive — 8 of them), and index 68–99 are 0 (actual is 0, so each pairing is a true negative — 32 of them). Inside confusion_counts, the line zip(actual, predicted) walks both lists together, pairing up each applicant's true label with the model's prediction, and each generator expression counts how many pairs match one of the four patterns. Run through fairness_report, the printed output is:

Locality A: TPR=0.70  FPR=0.20  Approval rate=0.50
Locality B: TPR=0.90  FPR=0.20  Approval rate=0.62

This matches the hand calculation exactly, which is the point: the arithmetic is simple enough to check by hand, and the code just makes it possible to run the same check automatically, per group, every time the model is retrained — something no one has time to do by hand on a production-sized dataset.

Why "Fair" Doesn't Have One Definition

Having a measurement toolkit doesn't automatically tell you what to fix. There are several mathematically distinct definitions of a "fair" model, and — this is the uncomfortable part — a model can satisfy one while badly failing another, using the exact same numbers.

  • Demographic parity requires the approval rate to be equal across groups. In the worked example, 50 percent versus 62 percent — this fails.
  • Equal opportunity requires the True Positive Rate to be equal across groups: among people who are genuinely qualified, the same fraction should be approved regardless of group. 70 percent versus 90 percent — this fails too.
  • Equalized odds requires both equal opportunity and an equal False Positive Rate. The FPR here is already tied at 20 percent, but since the TPR still differs, equalized odds fails as well.

There is a deeper result behind this that surprises most people the first time they meet it: around 2016 and 2017, several independent groups of computer scientists proved mathematically that when two groups have different underlying base rates for the outcome being predicted, it is generally impossible for a risk-scoring model to simultaneously satisfy calibration — meaning a given score means the same thing regardless of group — and equalized odds, except in special edge cases. This is not a limitation of any one company's engineering effort. It is a property of the mathematics itself. Which means choosing how to define "fair" for a particular system is not a purely technical decision that can be automated away — it is a value judgment about which kind of error matters more in that specific context, and it deserves input from the people affected, not just the engineers writing the code.

The Case That Made the World Argue About Fairness Math

This is not an abstract concern. In May 2016, journalists at ProPublica analyzed COMPAS, a risk-assessment tool built by the company Northpointe and used by courts in the United States to help judges decide on bail and sentencing. ProPublica compared the risk scores COMPAS assigned to thousands of defendants against who actually went on to reoffend, broken down by race. They found that among defendants who did not reoffend, Black defendants were nearly twice as likely as white defendants to have been wrongly flagged as high risk — a clear False Positive Rate disparity. Meanwhile, white defendants who did go on to reoffend were more often mistakenly scored as low risk than Black defendants who reoffended — a False Negative Rate disparity running in the opposite direction.

Northpointe, along with academic critics who later re-examined the data, responded with a different, equally correct observation: COMPAS was well calibrated. Among defendants who received the same risk score, roughly similar proportions actually went on to reoffend, regardless of race. Both claims — the false-positive disparity ProPublica reported, and the calibration Northpointe defended — turned out to be true at the same time. This was not a mistake by either side. It was the exact impossibility result described above, playing out with real consequences for real people's liberty, because the two racial groups in that dataset had different underlying reoffense rates. COMPAS could be race-blind by one legitimate definition of fairness and race-biased by another legitimate definition, simultaneously, using the same numbers. This is precisely why the field now insists that anyone deploying a risk-scoring system name, in advance, exactly which fairness definition they are optimizing for, and explain why.

When the Technology Itself Is Biased

Bias doesn't only live in training data and mathematical trade-offs; sometimes it lives in the hardware. India's Aadhaar biometric identity system is used, among many other things, to authenticate beneficiaries collecting subsidized food grain through the Public Distribution System. Researchers, including economists Jean Drèze and Reetika Khera, documented cases across states such as Rajasthan and Jharkhand where genuinely eligible families were turned away from ration shops because a fingerprint scanner failed to match a beneficiary's fingerprint. This failure is not random: it clusters heavily among people whose fingerprints have become worn or faded from decades of manual labour, and among the elderly, whose skin loses the fine ridge detail that fingerprint sensors rely on. The people most likely to be excluded by the technology are, disproportionately, the exact population a welfare programme exists to reach.

This matters as a distinct category from everything discussed so far, because the biometric sensor itself was never trained on a dataset containing enough worn, calloused, or aged fingerprints to work reliably on them — the bias here sits in the physical measurement device and the population it was tested on, not in a statistical pattern learned from historical decisions. "AI bias" is often discussed purely as a data-and-algorithm problem, but any system that senses the physical world can encode the same kind of systematic exclusion in its hardware.

Building Fairer Systems: What Engineers Can Actually Do

None of this means AI-driven decisions should be abandoned — loan approvals, resume screening, and identity verification at scale would be practically impossible to do by hand for millions of people. It means fairness has to be treated as an explicit engineering requirement with its own tests, not an afterthought bolted on after launch. Several practices, used together, make a meaningful difference.

  • Audit the training data before training begins: check how well each relevant group is represented, and actively search for features that might act as proxies for protected attributes, the way postal code can proxy for community or economic background.
  • Do not rely on fairness through unawareness. Deleting a sensitive column does not remove the information if correlated proxies remain in the dataset.
  • Choose a fairness definition deliberately for the specific decision at hand — demographic parity, equal opportunity, or something else — and document why, involving domain experts and, where possible, the communities affected, rather than leaving the choice implicit in whatever the code happens to optimize.
  • Test performance broken down by subgroup as standard practice, the way the confusion matrices above were built separately for Locality A and Locality B, rather than trusting one aggregate accuracy figure.
  • Keep monitoring after deployment. The population applying for loans this year may differ subtly from the population the model was trained on two years ago, a phenomenon called data drift, and feedback loops like the predictive-policing example can make a model quietly less fair over time without a single line of its code changing. An algorithmic audit — a scheduled, subgroup-by-subgroup recheck of real-world error rates, repeated on an ongoing basis rather than performed once before launch — is how teams catch this kind of drift before it causes harm at scale.
  • Keep a meaningful human in the loop for high-stakes decisions: loans, hiring, parole, medical diagnosis, and college admissions all carry consequences serious enough that a human should be able to review and override an automated call.
  • Build the system with a team of people who bring different lived experiences to the table. Blind spots are, by definition, easiest to miss for the people who share them, and hardest to miss for someone who doesn't.

This is increasingly a legal expectation as well as an ethical one. The European Union's AI Act, which entered into force in 2024, requires "high-risk" AI systems — including tools used for credit scoring, hiring, and access to essential services — to be tested and documented for exactly this kind of bias before deployment. In India, NITI Aayog has published national strategy papers calling for similar responsible-AI practices. Fairness auditing is moving from best practice to baseline requirement.

Back to Rohan

Return to the loan that took three seconds to reject. If the lending app's model used Rohan's postal code, or something correlated with it, as a feature — the density of registered businesses nearby, average neighbourhood income bought from a data broker, anything tied to location — it could easily have learned to associate his locality with higher default risk from patterns in its training data, even though Rohan personally had a verifiable UPI transaction history showing steady income. A fairer system would weight features that are directly and causally tied to his own ability to repay — his own transaction history, his own repayment record, his own income stability — far more heavily than anything tied to his neighbours. And critically, it would be tested the way Locality A and Locality B were tested above: broken down by group, checking whether equally qualified applicants from different localities are approved at similar rates, not just trusting one clean-looking overall accuracy number.

AI systems feel neutral because they are made of numbers and code, but the data behind those numbers is a record of human decisions, and human decisions have never been perfectly fair. Building ethical AI means asking, for every system before it ships: what data trained this model, and who is underrepresented in it? Which specific definition of fairness is it optimizing for, and what does that choice trade away? And who is checking its subgroup-level error rates after launch, on an ongoing basis, so that a problem like Rohan's doesn't have to be discovered by the person it happens to. The rejection Rohan received felt instant and objective. It was neither — it was a decision, made by people, encoded into a model, and it can be made fairer by people who choose to look for exactly the kind of gap this chapter just showed you how to find.

Think About It

Think about this: How would you explain ai bias and fairness: building ethical ai systems to a friend who has never seen a computer? What real-world analogy would you use? Imagine you had to build a system using these concepts — what would be your first step? Try this: before moving on, write down three things you learned and one question you still have.

Key Takeaways — Summary and Recap

Let us recap what we covered: the core ideas behind ai bias and fairness: building ethical ai systems, how they connect to real-world applications, and why they matter for your journey in computer science. Remember these key points as you move forward. For competitive exam preparation (CBSE, JEE, BITSAT), focus on understanding the WHY behind each concept, not just the WHAT.

← Dimensionality Reduction with PCA: Compressing Data Without Losing InformationIndia's National AI Strategy: IndiaAI Mission and Digital India →

Found this useful? Share it!

📱 WhatsApp 🐦 Twitter 💼 LinkedIn