What Is a Loss Function?

1 min

A loss function is how the computer grades its own mistakes — a smaller number means a better job.

Imagine it like this: In darts, missing the bullseye by a lot gives you a bad score, and missing by just a tiny bit gives you a much better score. A loss function does the same: it measures how far off each guess was, so the model knows exactly how much it needs to improve.

Examples:

  • Measuring how far off a predicted house price is from the true price
  • Measuring how confident a wrong "cat vs. dog" guess was

So? The loss function is the model's report card after each guess — and the whole goal of training is to make that score as small as possible.