# My Model Was 87% Accurate and Almost Perfectly Calibrated.

> Source: <https://pub.towardsai.net/my-model-was-87-accurate-and-almost-perfectly-calibrated-d7732cd516ef?source=rss----98111c9905da---4>
> Published: 2026-11-24 20:01:01+00:00

**Recommendation:** Run fairness checks on the full dataset, not a speed sample: a 12,000-row sample shrank the smallest race group to 26 people and moved race equalized odds from 0.135 to 0.647.
More in the playbook "Evals and testing for LLM apps": <https://wpnews.pro/playbooks/evals-testing>

Most machine learning portfolios show a model being built. Very few show a model being audited, and auditing is the step that decides whether a model ships.

So I built [model-audit](https://github.com/Emart29/model-audit). You hand it a fitted scikit-learn, XGBoost or PyTorch model, and it gives you back:

Every method except SHAP is written by hand, in code short enough to read. A fairness tool whose definitions you cannot inspect is not an audit tool. It is a second black box.

Then I pointed it at a model.

*The live demo at* *model-audit.streamlit.app**.*

The model is a gradient-boosted classifier trained on the UCI Adult census extract: 48,842 people, predicting whether income is above $50K. I scored it on a held-out quarter, 12,211 rows.

An expected calibration error of 0.007 means that when this model says “70%”, it is right about 70% of the time. By the measures most teams check, this model is finished.

Five of eight checks fail. The model predicts “>$50K” for 25.6% of men (n = 8,147) and 8.4% of women (n = 4,064). That is a selection ratio of 0.33. The “four-fifths” convention from US employment guidance flags anything below 0.80.

The explanations agree. Ranked by mean absolute SHAP value, sex=Female is the 6th most important of 91 features. It sits above capital loss and above every occupation. The model is not working out sex from proxies. It is using the column.

Here is where the story gets more honest, and more useful.

For sex, demographic parity fails but equalized odds passes. Those two checks ask different questions:

The model can fail the first and pass the second because the groups differ in the data itself. In this 1994 extract, 11.0% of women and 30.4% of men earn above $50K. A perfectly accurate model would still select men at almost three times the rate.

So how much of the gap does the model create? I compared the model’s selection ratio with the ratio already in the data:

So the model did not invent the gap. But it falls further short for women than for men. For every 100 men who really earned above $50K, it picked about 84 men. For every 100 such women, it picked about 76. In relative terms, women’s share of the picks shrinks. Then there is the error that hurts most. Among women who really did earn above $50K, the model found 59.6%. Among men, it found 66.0%. Qualified women are missed more often.

This is the real point of the project. “Is this model fair?” has no single answer, because different definitions of fairness cannot all hold at once when groups have different base rates. That is a known result, not a flaw in this model. An audit’s job is not to hand down a verdict. It is to put every definition on the table with its numbers, so the people deciding can see which trade-off they are making.

All four of these happened after every test had passed. I found them by running the full audit and reading what it said.

2. The fix exposed a second problem. With the cap gone, every row got the same advice: “have $15,024 of capital gains.” That is true for the model and useless to a person, because capital gain measures wealth, not a choice. With capital gain and loss treated as non-actionable, the search proposes changes to education, hours, occupation and sector. For rows it cannot honestly flip, it returns nothing: 17 of the first 40 rejected rows got a real counterfactual.

3. The importance chart was in alphabetical order. The bar chart sorted features alphabetically, so the “top features” chart showed age first and sex=Female last. A ranking chart that is not ranked tells the reader the wrong thing. You only see that by looking at the page.

4. The demo disagreed with the README. It defaulted to a 12,000-row sample for speed. That shrank the smallest race group to 26 people and moved race equalized odds from 0.135 to 0.647. The interface did warn about it, but only on one tab. The demo now runs on the full dataset by default, and every check shows its smallest group’s n.

There was a fifth, smaller one. Three tests passed on my machine and failed on GitHub, because my environment already had two optional dependencies installed that CI did not. A green local run is a claim about your machine, not about the code.

The next project in this series moves from auditing a classical model to the layer that decides whether an LLM change ships: an eval harness that catches regressions before users do.

*I’m Emmanuel Nwanguma, an ML and AI engineer in Lagos.* *View My Portfolio*

[My Model Was 87% Accurate and Almost Perfectly Calibrated.](https://pub.towardsai.net/my-model-was-87-accurate-and-almost-perfectly-calibrated-d7732cd516ef) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.
