Algorithmic Fairness Metrics Calculator
Introduction to Algorithmic Fairness Metrics Checks
When a classifier influences lending, hiring, healthcare triage, moderation, or another high-stakes decision, teams need more than a single accuracy score to understand whether the model behaves differently for different groups. This calculator is built for that audit workflow. It takes two confusion matrices and turns them into four fairness comparisons so you can see where Group A and Group B diverge instead of relying on intuition alone.
Use it when you want a compact snapshot of demographic parity, equal opportunity, predictive parity, and false positive rate differences. The counts you enter are treated as the raw outcomes for each group, so the results reflect the model’s actual error pattern rather than a synthetic score or a hand-waved summary.
How the Algorithmic Fairness Formulas Are Built
Fairness metrics begin with the same four cells used in any confusion matrix:
- True Positives (TP): Correct positive predictions
- False Positives (FP): Incorrect positive predictions
- False Negatives (FN): Missed positive cases
- True Negatives (TN): Correct negative predictions
From those counts, the calculator derives the group-level rates that fairness audits usually compare:
- True Positive Rate (TPR) or Sensitivity: Probability of correctly predicting positive cases.
- False Positive Rate (FPR): Probability of incorrectly predicting positive cases.
- False Negative Rate (FNR): Probability of missing positive cases.
- True Negative Rate (TNR) or Specificity: Probability of correctly predicting negative cases.
Positive prediction rate, which underlies demographic parity, is the share of each group that receives a positive label:
Precision, also called positive predictive value, is the share of positive predictions that are actually correct:
Once the rates are available, the calculator compares them between the two groups. Demographic parity looks at positive prediction rates, equal opportunity looks at true positive rates, predictive parity looks at precision, and false positive rate difference shows how often each group is incorrectly flagged. In other words, the calculator separates selection-rate balance from error-rate balance, which is important because a model can look acceptable on one measure and still be lopsided on another.
Worked example: fairness rates for two applicant groups in a loan audit
To make the fairness metrics concrete, imagine a loan-screening model reviewed for two applicant groups. The counts below are a compact audit snapshot, not a synthetic benchmark, and they show that similar totals can still hide different error profiles.
- Group A: TP=420, FP=60, FN=80, TN=440
- Group B: TP=360, FP=110, FN=90, TN=440
Calculate the True Positive Rate (TPR) for each group:
Group A:
Group B:
In this example, the equal-opportunity comparison is slightly in Group A’s favor because Group A’s true positive rate is 0.04 higher.
Fairness metric comparison table for the two groups
| Metric | Group A | Group B | Difference (A - B) | Interpretation |
|---|---|---|---|---|
| True Positive Rate (TPR) | 0.84 | 0.80 | 0.04 | Group A detects positives slightly better. |
| False Positive Rate (FPR) | 0.12 | 0.20 | -0.08 | Group B has more false alarms. |
| False Negative Rate (FNR) | 0.16 | 0.20 | -0.04 | Group B misses more positives. |
| True Negative Rate (TNR) | 0.88 | 0.80 | 0.08 | Group A correctly identifies negatives better. |
Limitations and assumptions in algorithmic fairness audits
Like every fairness calculator, this one summarizes a real model with a few carefully chosen rates, so it is useful—but not complete—by design.
- Data Quality: The fairness output is only as trustworthy as the confusion-matrix counts you provide. If the source labels are noisy or the sample is unrepresentative, the comparison can point in the wrong direction.
- Group Definitions: Group A and Group B need to be defined consistently before you interpret the rates. If the groups overlap, shift over time, or mix different populations, the comparison is harder to defend.
- Context Matters: No single metric captures the whole fairness story. A model can look balanced on one metric and still be lopsided on another, so you should interpret the numbers alongside the decision context.
- Threshold Sensitivity: Changing the classification threshold changes TP, FP, FN, and TN, which means the fairness gaps can move even when the underlying model stays the same.
- Statistical Significance: Tiny samples can make a small change look large. Treat very small group counts as directional evidence rather than a final verdict.
One practical implication is that the same model may appear fair under one threshold and less fair under another, so threshold choice should be documented along with the metric values. Another is that fairness comparisons are most useful when the two groups were evaluated on the same task, at the same time, and with the same label definition.
Frequently Asked Questions about Algorithmic Fairness Metrics
What is the purpose of comparing confusion matrices between groups?
Comparing confusion matrices for Group A and Group B shows whether the model makes more correct calls, misses, or false alarms for one group than the other. That makes the fairness gaps easier to diagnose and explain.
Can this calculator handle more than two groups?
This calculator compares two groups at a time. If your audit covers more than two groups, run separate pairwise checks so each comparison stays clear and easy to read.
How do I interpret a large difference in False Positive Rates?
A large false positive rate gap means one group is being flagged incorrectly more often. In a screening or review workflow, that can translate into extra burden, delay, or denial for that group.
Are these fairness metrics sufficient to ensure ethical AI?
No. They are a useful diagnostic layer, but they do not settle the fairness question on their own. Ethical review also needs context, stakeholder input, and policy or legal review.
What if my confusion matrix counts are zero or very small?
Very small counts can make the rates unstable, and any rate with a zero denominator will display as a dash instead of a percentage. Treat that as a warning that you need more data or a broader sample.
Does this calculator adjust for imbalanced datasets?
No. It computes the rates directly from the counts you enter, so you should always read the group totals and rate differences together when the sample sizes are uneven.
Why Algorithmic Fairness Metrics Matter in Practice
Models that affect loans, jobs, medical care, public benefits, fraud review, and content moderation can look accurate overall while still treating groups differently. That is why fairness reviews usually start with side-by-side confusion matrices: they expose whether one group receives more correct predictions, more misses, or more false alarms. This calculator turns those raw counts into the comparisons that auditors, researchers, and product teams need when they want a quick fairness snapshot without opening a spreadsheet.
Fairness is not one single number. In practice, teams compare several definitions because each one highlights a different kind of harm. Some reviewers care most about whether groups receive positive predictions at similar rates. Others want to know whether qualified people are equally likely to be identified, whether precision is balanced, or whether one group is more likely to be incorrectly flagged. The metrics in this calculator let you check those questions one by one instead of collapsing them into a vague overall score.
At the heart of the calculation is the confusion matrix, the same four-cell summary used in ordinary model evaluation. For each group, the matrix tells you how many true positives, false positives, false negatives, and true negatives the classifier produced. Once those counts are known, the fairness view comes from comparing the derived rates for Group A and Group B. That comparison is what makes the output meaningful in an audit setting: the raw counts stay visible, but the rates make the disparity easier to see.
Demographic parity, also called statistical parity, asks whether the model predicts a positive outcome at the same rate for both groups. Formally, it compares P(Ŷ = 1 | A) and P(Ŷ = 1 | B). The difference reported by this calculator is the gap between those positive prediction rates. If the difference is close to zero, both groups are being selected at about the same rate. If it is large, the model may be favoring one group in the selection process even if its overall accuracy looks acceptable.
Equal opportunity focuses on the true positive rate, which tells you how often qualified cases are correctly identified. In plain language, it asks whether people who should receive the positive outcome have an equal chance of being recognized by the model. The true positive rate, also known as sensitivity or recall, is defined as . The Equal Opportunity Difference computed by this tool is TPRA − TPRB. Positive values show that Group A is being recognized more often, while negative values indicate that Group B is.
Predictive parity looks at precision, or positive predictive value, which answers a different question: when the model predicts a positive outcome, how often is that prediction actually correct? This matters when a system makes a lot of decisions but only some of them are supposed to be trusted or acted on. The Predictive Parity Difference is PPVA − PPVB. A gap here can mean that one group receives more misleading positive predictions even if the model appears balanced on another metric.
False positive rate difference is especially useful when false alarms are costly. The false positive rate is . The calculator reports FPR Difference as FPRA − FPRB. If one group is more likely to be wrongly flagged, the model may create extra review steps, unnecessary denials, or other downstream burdens for that group.
The table below maps each metric to the fairness idea it captures:
| Metric | Definition | Fairness Notion |
|---|---|---|
| Demographic Parity Difference | Difference in positive prediction rates | Equality of Outcomes |
| Equal Opportunity Difference | Difference in true positive rates | Equality of Opportunity |
| Predictive Parity Difference | Difference in positive predictive values | Predictive Equality |
| False Positive Rate Difference | Difference in false positive rates | Error Rate Balance |
Example audit snapshot for algorithmic fairness metrics
The sample counts below represent a simplified weekly audit of a loan approval model. They show how two groups can end up with similar totals while still generating different fairness rates.
| Group | TP | FP | FN | TN | Positive Rate | TPR | PPV | FPR |
|---|---|---|---|---|---|---|---|---|
| Group A | 420 | 60 | 80 | 440 | 48% | 84% | 87.5% | 12% |
| Group B | 360 | 110 | 90 | 440 | 47% | 80% | 76.5% | 20% |
Even with matching true negative counts, Group B’s higher false positive rate is a signal to review the threshold, the training data, or both before deploying the model.
Those differences also show why fairness work is full of trade-offs. A model can be tuned to reduce one gap and unintentionally widen another. Scholars sometimes describe these tensions as fairness impossibility results: unless the groups share the same underlying base rates, it is often not possible to satisfy every fairness criterion at once. For that reason, the right metric is usually the one that matches the decision you are making and the harm you are trying to reduce.
The calculator uses straightforward arithmetic on the counts you enter. It computes each group’s rates separately and then subtracts Group B from Group A for the comparison metrics. Because the calculation happens in the browser, the summary appears immediately and the underlying counts stay on your device. That makes the tool practical for quick audits, teaching sessions, and early-stage model reviews.
Interpretation still depends on the business or social setting. In a hiring model, for example, a demographic parity gap can suggest that one group is being screened out more often than the other. In a loan model, a false positive gap may mean that one group is being denied or routed to manual review at a higher rate even when the model is uncertain. The same numeric result can mean very different things depending on whether the positive outcome is desirable, protective, or costly.
Fairness checks also matter in facial recognition, toxicity detection, fraud screening, and recommendation systems. Researchers have repeatedly found that models can perform unevenly across skin tones, dialects, or other subgroup characteristics, which shows up directly in rates like TPR and FPR. By reducing those differences to clear percentages, this calculator gives you a practical way to inspect whether a model’s behavior is drifting toward one group or another.
Mathematically, these fairness quantities are conditional relationships between the true label, the prediction, and the group attribute. Let represent the true label, the prediction, and the group attribute. Demographic parity enforces , equal opportunity enforces , and predictive parity enforces . Those identities are a reminder that fairness is not just about total accuracy; it is about how the model’s errors and successes are distributed across groups.
Practitioners often use fairness metrics alongside mitigation techniques such as reweighting, threshold adjustment, or post-processing corrections. A reweighted training set can reduce the pressure toward majority-group patterns, while a different threshold can shift the balance between false positives and false negatives. This calculator is useful after those steps because it lets you check whether the new settings actually moved the rates in the direction you expected.
In documentation and compliance work, the numbers can also be evidence. Teams use these metrics in audit reports, model cards, and internal reviews to show how a model behaves before and after intervention. The calculation is lightweight, but the result is often important enough to share with product managers, legal teams, or outside reviewers who need a concise summary of group-level behavior.
The conversation around algorithmic fairness keeps evolving, and the metrics in this calculator are only one piece of that larger debate. Statistical parity is not always the right goal, and sometimes the most important issue is minimizing harm in the specific decision context. Even so, these comparisons are still valuable because they turn a broad fairness discussion into numbers that can be checked, repeated, and challenged.
To get started, collect the confusion-matrix counts for the two groups you want to compare. Those counts might come from a validation set, a model audit, a production report, or a manual review sample. Enter the values into the form and read the differences with care: positive values mean Group A’s rate is higher, negative values mean Group B’s rate is higher, and zero means the two groups are tied on that metric. If a denominator is zero, the calculator shows a dash in the affected rate cell so you can immediately see that the metric cannot be computed from the counts you entered.
You can also use the calculator as a what-if tool. If you want to understand how a threshold change might affect fairness, adjust the counts to match the revised decision rule and compare the new result with the original scenario. That kind of side-by-side check is often more informative than looking at a single output in isolation because it shows which metric moves first and which one barely changes.
In short, algorithmic fairness metrics give you a structured way to inspect whether a model’s errors are distributed evenly across groups. This calculator keeps the arithmetic transparent, the comparison visible, and the result easy to copy into a report. Whether you are learning the basics of responsible AI or checking a model before deployment, the goal is the same: make group-level performance visible before it turns into a hidden problem.
Related Fairness and Classification Calculators
Extend your bias audit with the Algorithmic Fairness Bias Metric Calculator, translate model performance into confusion-matrix KPIs with the Confusion Matrix Metrics Calculator, and experiment with model coefficients using the Logistic Regression Calculator.
How to use this algorithmic fairness metrics calculator
- Enter True positives for Group A and Group B using the same label definition you used when scoring the model.
- Enter False positives from the same evaluation pass so the comparison stays aligned.
- Enter False negatives from that same dataset or audit sample.
- Run the calculation, then adjust one group or threshold scenario and compare the new fairness gaps before you act on the result.
