What is a computer model?

Bryan de Bourbon · · Draft

Give a model a photo from a park and ask it to find the birds. It might trace a bird cleanly, miss a wing in shadow, or label a leaf as part of the bird. Those outcomes tell you something about what the model learned. To decide whether you can rely on it for the next batch of photos, you need to know how often each one happens.

What goes in and what comes out

A model is a mathematical function that maps inputs to outputs. In machine learning, training adjusts the function using data. At prediction time, the model takes a new input and produces an answer. For a bird photo, the input might be an array of pixel values. The output might be one score for the whole image, a box around each bird, or a score for every pixel. Apply a threshold to those pixel scores and you get a mask that says where the model thinks the bird is.

A prediction is the model’s answer. A label is the reference answer used to check it. The label depends on an annotation decision. If the task includes visible tail feathers in a bird mask, whoever draws the reference needs to apply that rule consistently. Otherwise, some apparent model error comes from disagreement about the task.

Four ways a prediction can land

Pick one class and call it positive. In a cat-versus-dog example, a cat correctly called a cat is a true positive, and a dog correctly called a dog is a true negative. A dog called a cat is a false positive. A cat called a dog is a false negative. A confusion matrix puts all four outcomes in one place, with the reference labels on the rows and predictions on the columns.

Cat-versus-dog confusion matrix with three true positives, one false negative, two false positives, and four true negatives.
Figure 1. With cat as the positive class, the model gets seven of ten photos right. It calls five photos cats, and three of those really are cats.

That gives us three answers from the same ten photos. Accuracy is 7 out of 10, or 70%. Precision asks how many of the model’s cat calls were right, which is 3 out of 5, or 60%. Recall asks how many of the actual cats it found, which is 3 out of 4, or 75%. In a large photo collection, missed birds and false alarms can have different costs. If each flag goes to a reviewer, precision tells you how much of that review is likely to pay off. Recall tells you how much of the birds you’re picking up.

How three masks can get the same score

At the pixel level, a large background can dominate accuracy. In the digit example below, an empty foreground prediction would still get about 63% of the pixels right. Three other predictions each get about 77%, even though one finds only part of the 8, one covers the whole digit and spills into the background, and one makes both kinds of error.

Five pixel grids show the reference digit 8, a perfect mask, an underprediction, an overprediction, and a partial overlap. The final three all score 0.77 accuracy, with IoUs of 0.38, 0.62, and 0.50.
Figure 2. The last three masks tie on pixel accuracy. Their foreground IoUs are 0.38, 0.62, and 0.50. Look at the top and bottom loops to see how their errors differ.

Intersection over union (IoU) measures overlap. Count the pixels that both the prediction and reference mark as foreground, then divide by the number that either one marks as foreground. The same overlap idea works for bounding boxes using area instead of pixel counts.

IoU = true positives ÷ (true positives + false positives + false negatives)

Mean IoU (mIoU) averages IoU across the evaluated classes. Each included class gets equal weight in that average, even when the background fills most of the frame and a bird takes up only a few pixels. I’d look at pixel accuracy, mIoU, and the individual class scores together. The class scores tell me where to open the images and start looking.

Where the model disagrees with a person

A confusion matrix is just as useful when the model makes one judgment per image or review item. In this comparison, a vision-language model could label an item good, suspect, or bad. A human reviewer marked each item good or bad.

Of 11 items marked good by a human, the model marked four good and seven bad. Of nine items marked bad by a human, the model marked all nine bad. The model used suspect zero times.
Figure 3. The model and reviewer agreed on 13 of 20 items. All seven disagreements were items the reviewer marked good and the model marked bad.

The 65% agreement rate is a start. The direction of the disagreements tells me what to investigate. The model flagged all nine items the reviewer marked bad, and it also flagged seven of the eleven the reviewer accepted. If every bad verdict sends an item to manual review, I’d open those seven items first and look for a common reason the model flagged them.

Will it hold up on the next batch of photos?

I’d test on photo collections held out of training and group the results by class, capture date, and conditions. A dataset average can hide two clusters of performance. A model might work well on bright close-ups and struggle with distant subjects in low light. The distribution shows whether those failures are isolated or routine. The lowest-scoring groups tell you where to look, and a confidence interval around an average tells you how much uncertainty there is in that estimate.

If confidence scores decide which predictions get reviewed, I’d check those separately. When the model assigns about 90% confidence to a set of predictions, are roughly 90% correct? I’d ask that again as new photos come in, especially when cameras, lighting, or locations change.

For one bird photo, I want to know whether the mask follows the outline. Across a collection, I want to know which birds the model tends to miss, what else it mistakes for a bird, and how often those errors happen under the conditions we’ve tested.

Themes to be expanded on

  • F1 score, ROC curves, and precision–recall curves across decision thresholds
  • Mean, median, variance, standard deviation, and confidence intervals for model scores
  • Error distributions, bimodality, worst-case performance, and per-class variation
  • Calibration curves and how confidence changes over time
  • Cross-entropy, focal loss, and Dice loss for training segmentation models
  • Normalized cross-correlation for comparing aligned views under changes in brightness and contrast