← All writing
Evaluation · 5 min read · 4 Dec 2026

Building a Lightweight Model Evaluation Harness in an Afternoon

You do not need a sprawling framework to evaluate models properly. A few hundred lines of disciplined code will catch most of the mistakes that quietly wreck published numbers.

Cover image for the article: Building a Lightweight Model Evaluation Harness in an Afternoon

Why bother writing your own

Most people evaluate models the way they learned to in a tutorial: split the data once, fit, call a metric function, report the number, move on. It works until it does not, and the failure mode is rarely loud. It is a quiet leak between train and test, a metric that silently ignores class imbalance, or a comparison between two models evaluated on slightly different folds. None of this throws an error. It just produces a number that looks fine and is wrong.

I used to reach for whatever evaluation utilities came bundled with a library, trusting that popular tools must be doing the right thing. The problem is not that these tools are bad; it is that I did not always understand what they were doing under the hood, which split strategy they defaulted to, or how they handled ties and missing predictions. Writing a small harness from scratch forces you to make every decision explicit. You cannot accidentally leak data through a default argument you never read.

The other reason is portability. A harness you built yourself, with no exotic dependencies, is something you can drop into any project in minutes. It becomes a habit rather than a one-off script, and habits are what actually produce reproducible research, not good intentions written in a README.

The core pieces, and why each one earns its place

A minimal harness needs four things: a deterministic split, a baseline, a metric suite, and a logging format. Leave any of these out and you lose the ability to trust your own results later.

The split comes first because everything downstream depends on it. Fix a random seed, write the split indices to disk, and never regenerate them casually. Say you have four thousand records split eighty-twenty. If you reshuffle before every run because you forgot to cache the split, your test set drifts by a few hundred records each time, and small improvements become unmeasurable noise. Saving the split once, as a plain list of indices or a hash, removes that uncertainty entirely.

The baseline matters more than people admit. Before you report that your model reaches seventy-eight percent accuracy, you need to know what a trivial majority-class predictor achieves. If seventy-two percent of your labels are the same class, a model that always predicts that class already scores seventy-two percent, and your six-point gain suddenly looks much less impressive. I always bake a majority-class or mean-value baseline directly into the harness so it runs automatically alongside every real model, never as an afterthought I might skip.

The metric suite should report more than one number. Accuracy alone hides imbalance; a single F1 score hides which class is failing. A compact harness computes precision, recall, and F1 per class, plus a confusion matrix, every single run. It costs almost nothing computationally and saves you from the awkward moment, weeks later, of realising your model never once predicted the minority class.

laptop with spreadsheet of data

A worked example you can hold in your head

Imagine a binary classification task with three thousand examples, where seventy percent belong to the negative class. You fix a seed, split sixty-twenty-twenty into train, validation, and test, and save the indices as a text file. The majority-class baseline, built into the harness, scores seventy percent accuracy and an F1 of zero on the positive class, because it never predicts positive at all. That number is now your floor.

You train a logistic regression and a small gradient-boosted model. The harness runs both through the identical split and the identical metric function, logging results to a single CSV: model name, seed, accuracy, precision, recall, F1 per class, and a timestamp. Logistic regression comes back at seventy-four percent accuracy but an F1 of 0.31 on the positive class. The gradient-boosted model reaches seventy-six percent accuracy with an F1 of 0.52 on the positive class. Without the per-class breakdown, you would have looked at accuracy alone and seen only a two-point gap, missing that the boosted model is nearly twice as good at the thing that actually matters.

Now repeat the run with three different seeds for the split itself, not just the model initialisation. If the boosted model's F1 ranges from 0.44 to 0.58 across seeds, you have learned something important: your test set is small enough that a single split cannot be trusted as the final word. That instability is invisible if you only ever ran one split, and it is exactly the kind of thing a five-minute addition to the harness, a loop over three seeds instead of one, will reveal.

This is also where leakage checks pay off. A simple assertion that no index appears in both the train and test sets, run automatically before training starts, catches an entire category of mistake that otherwise surfaces only when someone else tries to reproduce your pipeline and gets suspiciously perfect numbers.

Keeping it small on purpose

The temptation, once the harness works, is to keep adding features: plugin architectures, configuration files with dozens of options, support for every model type you might someday use. Resist this. The value of the afternoon build is that you understand every line of it. The moment it grows past a few hundred lines with clear functions for splitting, baselining, scoring, and logging, you have recreated the opacity you were trying to escape.

A good test of whether it is still lightweight: can you explain, from memory, exactly how the split was generated and exactly which metrics get logged for every run? If the answer is yes, the harness is doing its job. If you have to go and read your own code to remember, it has grown too large.

The practical takeaway is simple. Spend an afternoon writing a split function that saves its indices, a baseline that runs automatically, a metric function that reports more than accuracy, and a logger that appends every run to a single file. That combination will catch more real mistakes than most elaborate frameworks, precisely because you built it, you understand it, and you will actually use it every time.

handwritten notes and calculator on desk
← All writing See the project case studies →