Beyond Accuracy: A Practical Guide to Evaluating AI Models

What a metric measures and when it misleads: rare classes, MAE versus RMSE, detection mAP, LLM benchmarks and RAG, with a checklist for any reported score.

Sylla N'falyOct 17, 202610 min read

"Our model reaches 98% accuracy." You read this in product announcements, papers and job interviews. On its own, the sentence says little. It depends on what was counted, on which data, and on what the model was supposed to do.

A model that never flags anyone for a rare disease is 99% accurate when 99% of patients are healthy. It is also useless. A metric is evidence about one aspect of a model, measured on one dataset. It is not a certificate of quality.

This article covers the cases I meet most often: classification with rare positives, regression, object detection, and language models with retrieval. For each one, it shows what the usual metric says and where it misleads. The numbers in the examples are invented or simulated to make a point, and each was computed with a script (Python 3.11, scikit-learn 1.9). Results from research papers are cited.

First question: what does the test set prove?

A score is only as good as the data it was measured on. Three things go wrong often.

The test set was not really unseen. The training set fits the model, the validation set guides every human choice (architecture, threshold, when to stop), and the test set is used once, at the end. Each time a team looks at test results and changes something, the test set becomes a validation set and the score becomes optimistic.

Information leaked. The same patient appears in the training and test data, preprocessing was fitted on the whole dataset, or a time series was split at random so the model trains on the future. Kapoor and Narayanan list hundreds of published studies, across many fields, affected by leakage (Kapoor & Narayanan, 2023). When the data has that structure, split by patient, user, source or time.

The labels are not the truth. Reference labels come from people, rules or later events, and they contain mistakes. Northcutt et al. estimated that at least 3.3% of the labels in ten popular test sets are wrong on average, and at least 6% in the ImageNet validation set. Correcting them was enough to change which of two models looked better (Northcutt et al., 2021).

Classification: when positives are rare

A screening model examines 1,000 patients. Ten are sick. The model flags 48 patients, and 8 of them are sick. The four possible outcomes form a confusion matrix:

Predicted sickPredicted healthy
Actually sick (10)8 true positives2 false negatives
Actually healthy (990)40 false positives950 true negatives

Accuracy is the share of correct decisions: (8 + 950) / 1,000 = 95.8%. A "model" that declares everyone healthy finds nobody and scores 990 / 1,000 = 99.0%. When one class dominates, accuracy mostly measures how common that class is.

Three other rates describe the model better:

  • recall (or sensitivity): the share of sick patients found, 8 / 10 = 80%;
  • precision: the share of alerts that are right, 8 / 48 = 16.7%;
  • specificity: the share of healthy patients cleared, 950 / 990 = 96.0%.

In plain terms, the model finds 8 of the 10 sick patients and raises five false alarms for each true one. Precision here does not have its everyday meaning: in classification, it only concerns the positive predictions.

The threshold is a decision about costs

Most classifiers output a score, and a threshold turns it into a decision. Lowering the threshold finds more sick patients (recall rises) and raises more false alarms (precision falls). The right place depends on what each error costs. A spam filter wants very high precision, because hiding a real email is worse than letting one spam through. A screening test wants high recall, because a missed case costs more than a second test. Choose the threshold on validation data, and report it with every metric that depends on it.

Ten positives give a wide margin

Recall here is 8 out of 10. The 95% confidence interval for that proportion (Wilson score interval) runs from 0.49 to 0.94. The data fits a model that finds half of the sick patients as well as one that finds almost all of them. With 1,000 sick patients and the same 80% recall, the interval shrinks to 0.774–0.824. Always report how many examples sit behind a metric, and distrust small differences between models that come without an interval or a paired test.

ROC-AUC does not see the base rate

The ROC curve plots recall against the false positive rate for every threshold. ROC-AUC is the area under it: the probability that a random positive gets a higher score than a random negative. The precision-recall (PR) curve plots precision against recall, and average precision (AP) summarises it.

In the figure below, the model's scores follow the same distributions in both cases. Only the share of positives changes, from 50% to 1%.

ROC vs precision-recallAuthor's figure
ROC curve000.50.511False positive rateRecall (true positive rate)ROC-AUC 0.92 for bothPrecision-recall curve000.50.511RecallPrecisionAP 0.92 (50%) vs 0.26 (1%)
50% positives1% positives

The two ROC curves overlap (ROC-AUC 0.921 and 0.922). Average precision falls from 0.921 to 0.259. With 1% positives, catching 80% of them gives a precision of 0.060, so 94% of the alerts are false. The model did not change; the base rate did, and only the PR curve shows it. This is why PR analysis is recommended when positives are rare (Saito & Rehmsmeier, 2015).

A model can also rank cases well and still give scores that are not probabilities. If its output is used as a risk ("80% chance of fraud"), check its calibration with a reliability diagram: among the cases scored 0.8, about 80% should be positive (scikit-learn).

Regression: MAE, RMSE and R² disagree

Two models estimate the price of ten flats, in thousands of euros (mean price 248). Model A is off by 20 on every flat. Model B is off by 5 on nine flats and by 150 on the tenth.

ModelMAERMSEMedian absolute errorR²
A: always off by 2020.020.020.00.921
B: off by 5, once by 15019.547.75.00.549

MAE (mean absolute error) is the average size of an error, in euros. Model B wins narrowly, 19.5 against 20.

RMSE (root mean squared error) squares the errors before averaging, so large errors weigh much more. In model B, the single error of 150 accounts for 99% of the squared error, and RMSE jumps to 47.7. A large gap between MAE and RMSE means a few large errors. If one mistake of 150 thousand euros can kill a sale, model B is the worse model, and only RMSE says so. The median absolute error (5.0 for model B) does not see that mistake at all.

R² compares the model's squared error with that of a model that always predicts the mean price. An R² of 0.921 does not mean that 92.1% of the predictions are correct. It can also be negative: on the same flats, a model that always predicts 150 scores −1.92. And because R² depends on how varied the test data is, an R² of 0.9 on one dataset and 0.7 on another does not mean the first model is better.

MAPE (mean absolute percentage error) is popular in business reports because it has no unit, but it breaks near zero. Predicting 1.5 when the truth is 0.5 is a 200% error; predicting 900 when the truth is 1,000 is a 10% error. Averaged, the two give 105%, almost all of it from the smallest value (Hyndman & Koehler, 2006).

Object detection: what mAP@50 says

A detector draws boxes. A box counts as correct only if it overlaps a reference box enough, measured by intersection over union (IoU): the area the two boxes share divided by the area they cover together. IoU is 1 when the boxes coincide and 0 when they do not touch. The figure shows a 100 × 100 reference box and three predictions of the same size, shifted diagonally.

IoU and box positionAuthor's figure
shift 10 pxIoU = 0.68passes at 0.50, fails at 0.75shift 20 pxIoU = 0.47fails at 0.50, fails at 0.75shift 30 pxIoU = 0.32fails at 0.50, fails at 0.75
reference box (ground truth)predicted boxintersection

A shift of 20 pixels in each direction, a fifth of the box width, already drops IoU to 0.47. Anyone looking at that prediction would say the object was found. With the usual 0.5 threshold, the protocol records a false positive and a missed object.

Average precision is then computed for each class over all confidence levels, and mAP averages it over the classes. The name hides a choice. AP50 uses a single IoU threshold of 0.5. COCO's main metric, AP50:95, averages ten thresholds from 0.50 to 0.95 and rewards tight boxes. The YOLOv3 paper reports, for the same model on COCO, an AP50 of 57.9 and an AP50:95 of 33.0 (Redmon & Farhadi, 2018). My Tangier smart-tourism project reports mAP@50 = 0.820 for craft and food detection: the model finds and roughly places those objects, which says nothing about how tight its boxes are.

Two more points. AP covers all confidence thresholds, while a deployed detector uses one, so report precision and recall at that threshold too. And small objects are usually much harder: the same YOLOv3 results give an AP of 18.3 on small objects against 41.9 on large ones.

Language models: build your own test set

A large language model (LLM) does many tasks, so no single benchmark describes it. Public scores also drift away from what users experience:

  • Contamination. When test questions end up in the training data, the score measures memory. On GSM1k, a fresh set of maths problems built to mirror the GSM8K benchmark, several model families scored up to 8% lower (Zhang et al., 2024).
  • Prompt format. Changing only the formatting of a few-shot prompt moved one model's accuracy by up to 76 points (Sclar et al., 2024).
  • Label errors. One audit estimated that 6.49% of MMLU questions contain errors (Gema et al., 2024).

The practical answer is a small test set built from your own use: a few hundred real questions, reference answers written by someone who knows the domain, frozen and versioned so that every change of model or prompt is measured on the same cases.

An LLM judge needs checking

Grading open answers by hand is slow, so another LLM often grades them. It can work: GPT-4's verdicts agreed with human judges more than 80% of the time, about as often as humans agreed with each other (Zheng et al., 2023). But judges have biases. They favour longer answers, answers in their own style, and one position over the other. By swapping only the order of the answers, Wang et al. made Vicuna-13B beat ChatGPT on 66 of 80 questions, with ChatGPT as the judge (Wang et al., 2023).

Treat the judge as an instrument. Run pairwise comparisons in both orders and keep only consistent verdicts. Give it explicit criteria and a reference answer. Grade a sample by hand to measure how often it agrees with people, and check that agreement again whenever the judge model or its prompt changes.

RAG: score the retriever and the generator separately

A RAG system first retrieves passages, then an LLM writes an answer from them. Scoring only the final answer hides which stage failed. Take a policy that allows "up to two days of remote work per week, subject to manager approval":

  • the retriever returns the right paragraph and the model writes "at least two days": retrieval is perfect, the answer is not faithful to its source, and the fix belongs in the prompt or the model;
  • the retriever returns an unrelated page and the model answers "two days" from what it learned in training: the answer looks right, but the system got lucky, and the next policy that differs from common practice will expose it.

So measure retrieval on its own (recall@k: are the passages needed in the top k results?), then whether each claim of the answer is supported by the retrieved passages, then whether the answer is correct (Es et al., 2024). The RAG evaluation article shows how to run these checks before each release.

After deployment, the score moves

A test set is a snapshot. In production, the inputs change (a new camera, a new customer segment), the link between inputs and outcomes changes (a fraud pattern that was harmless last year), and the true labels often arrive weeks later. Monitor what you can see without labels (input statistics, the distribution of predictions, the average confidence), recompute the real metrics when the labels arrive, and run the frozen test set again before each release. Look at the whole system too: a good model behind a slow interface or a wrong document index still gives users a bad answer.

A checklist for "our model reaches 98% accuracy"

  • Accuracy of what? Which task, which exact metric, which threshold, which average over classes?
  • On which data? How was it collected and labelled, and how close is it to real use?
  • How was it split? Could the same people, sources or near-duplicates sit in both training and test data? Was anything tuned on the test set?
  • Compared with what? What does a trivial baseline score, and what does the current system score?
  • How sure is it? How many test cases and positives, and what confidence interval?
  • For whom does it fail? Results per class and per group, and the worst cases read one by one.
  • What do the errors cost? Minor confusions, or dangerous ones?

Without these answers, 98% tells you very little.


References

  1. scikit-learn developers. Metrics and scoring and probability calibration. Documentation, version 1.9.
  2. Kapoor, S., & Narayanan, A. (2023). Leakage and the reproducibility crisis in machine-learning-based science. Patterns.
  3. Northcutt, C. G., Athalye, A., & Mueller, J. (2021). Pervasive Label Errors in Test Sets Destabilize Machine Learning Benchmarks. NeurIPS 2021, Datasets and Benchmarks.
  4. Saito, T., & Rehmsmeier, M. (2015). The Precision-Recall Plot Is More Informative than the ROC Plot When Evaluating Binary Classifiers on Imbalanced Datasets. PLOS ONE.
  5. Hyndman, R. J., & Koehler, A. B. (2006). Another look at measures of forecast accuracy. International Journal of Forecasting, 22(4).
  6. Redmon, J., & Farhadi, A. (2018). YOLOv3: An Incremental Improvement. arXiv.
  7. Zhang, H., et al. (2024). A Careful Examination of Large Language Model Performance on Grade School Arithmetic. NeurIPS 2024, Datasets and Benchmarks.
  8. Sclar, M., Choi, Y., Tsvetkov, Y., & Suhr, A. (2024). Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design. ICLR 2024.
  9. Gema, A. P., et al. (2024). Are We Done with MMLU?. arXiv.
  10. Zheng, L., et al. (2023). Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena. NeurIPS 2023, Datasets and Benchmarks.
  11. Wang, P., et al. (2023). Large Language Models are not Fair Evaluators. arXiv.
  12. Es, S., James, J., Espinosa-Anke, L., & Schockaert, S. (2024). RAGAS: Automated Evaluation of Retrieval Augmented Generation. EACL 2024, System Demonstrations.
All posts