Back to field notes
FIELD NOTE / MACHINE LEARNING

Evaluating machine learning models beyond accuracy

Precision, recall, class imbalance, and the uncomfortable questions a single score can hide.

READING NOTE

These are personal learning notes: practical explanations, trade-offs, and questions worth exploring further.

The starting point

A model can make mostly correct predictions and still fail at the task that matters. When one class is much more common than another, accuracy can hide the errors that deserve the most attention.

First principles

Start with the cost of a mistake. Precision asks how many predicted positives were correct. Recall asks how many actual positives were found. Neither metric wins in every situation; the use case determines the trade-off.

ConceptWhat it meansWhy it matters
AccuracyCorrect predictions / all predictionsUseful when classes and error costs are reasonably balanced
PrecisionCorrect positives / predicted positivesUseful when false alarms are expensive
RecallCorrect positives / actual positivesUseful when missed positives are expensive

A practical example

A small example helps make the idea concrete. This snippet is illustrative; it assumes the surrounding data and setup are already in place.

from sklearn.metrics import classification_report

predictions = model.predict(X_test)
print(classification_report(y_test, predictions))

What to take away

Use a held-out test set, inspect the confusion matrix, and compare with a simple baseline. A good evaluation makes trade-offs visible instead of hiding them behind one number.

The goal isn’t to memorize a recipe. It’s to understand the choices well enough to make them deliberately.

← All notesNext article