Loss: measuring prediction errors
As a model learns from examples, it can try to reduce a score called loss. Yet a lower loss score does not automatically mean a more useful model in the real world.
From a guess to an error score.
In supervised learning—learning from examples paired with known answers—training is the stage when a model adjusts learned settings. For each example, it predicts an output and compares it with the known value, called the target. A score can summarize how far its predictions miss.
In this lesson, you will follow five ideas in order: one prediction error, one combined score, how averaging and squaring errors differ, sliding a line to change the score, and why a low score alone does not show real-world usefulness.
Prediction error
The signed gap for one example: actual − predicted. A positive gap means the actual value is larger than the prediction.
Loss function
A rule that scores each prediction error and combines the scores, often by averaging, into one number called loss.
Think of a commute estimate: if you predict 25 minutes and the trip takes 35, the error is +10 minutes. A weekly loss score summarizes the five daily misses, much like one average for several quiz marks.
Rohan (an invented local courier for this lesson) predicts delivery time in minutes from distance in kilometers using a simple line: 10 minutes pickup base + 4 minutes per km. The slope is the added minutes for each extra kilometer. Here are five invented recent trips: 1 km → 14 min, 2 km → 18 min, 3 km → 22 min, 4 km → 26 min, and 5 km → 52 min after a bridge closure. That last time sits far from the others; such an unusually distant value is called an outlier.
With a slope of 4 minutes per km, Rohan’s line predicts 14, 18, 22, 26, and 30 minutes. The first four trips have zero error, while the 5 km bridge-delay trip is off by +22 minutes. Averaging the five error sizes without their signs gives a score of 4.4 minutes. This is the mean absolute error, or MAE.

Different loss functions punish mistakes differently.
Not every loss function treats a big miss the same way. Two common loss functions for numeric predictions are MAE (Mean Absolute Error) and MSE (Mean Squared Error).
MAE (Mean Absolute Error)
Drops the minus sign on each error and takes the average. Every extra minute of error adds the same penalty, whether the miss is 2 minutes or 22 minutes.
MSE (Mean Squared Error)
Squares each error before averaging. A 2-minute miss becomes 4, while a 22-minute miss becomes 484—over a hundred times larger.
Because MSE squares large misses, it pulls Rohan’s line upward toward the 52-minute bridge-delay trip. On this dataset, MAE picks 4.0 min/km (MAE = 4.4 min, MSE = 96.8), fitting the four typical trips cleanly. MSE picks 6.0 min/km (MSE = 52.8, MAE = 6.4 min), shrinking the one huge squared error at the cost of overestimating every typical trip by 2 to 8 minutes.
For an everyday comparison, imagine two weather apps: one is off by 1°C every day, while another is exact four days a week and off by 15°C on Friday. Which feels worse depends on whether one huge surprise hurts you more than steady small misses.
A scoring rule also affects what the model is encouraged to improve: the choice of loss defines how different prediction misses count.

Slide a line and watch the loss change.
Try adjusting Rohan’s prediction line below. Like a ruler laid across five pins on a board, moving the slope changes every trip’s vertical error bar at once—and MAE and MSE score that trade-off differently.
- Start on MAE at 4.0 min/km. Notice that four trips have 0 error while the 5 km bridge-delay trip has a +22 min error (MAE = 4.4 min, MSE = 96.8).
- Switch the highlight to MSE, then slide up to 6.0 min/km (or click Best MSE (6.0)). Watch MSE drop from 96.8 to 52.8 while MAE climbs from 4.4 to 6.4 min.
- Compare the table rows at 6.0 min/km: lowering MSE made all four typical trips less accurate just to shrink the single squared outlier error.
- Click Reset line to return to the starting setup.
Lowest possible: 4.4 min at 4.0
Lowest possible: 52.8 at 6.0
| Trip | Actual | Predicted | Error | Abs error |
|---|---|---|---|---|
| 1 km (Typical) | 14 min | 14 min | 0 min | 0 min |
| 2 km (Typical) | 18 min | 18 min | 0 min | 0 min |
| 3 km (Typical) | 22 min | 22 min | 0 min | 0 min |
| 4 km (Typical) | 26 min | 26 min | 0 min | 0 min |
| 5 km (Bridge delay) | 52 min | 30 min | +22 min | 22 min |
Illustrative toy dataset: five invented trips with a fixed 10-minute pickup base, designed to show how MAE and MSE react differently to a single large outlier.
Why low loss does not guarantee a useful model.
It is tempting to assume that whichever model has the lowest loss is automatically the most useful. A low loss score means predictions fit a chosen scoring rule on a chosen set of recorded targets. It does not by itself tell us whether people get a useful result.
Different costs for different mistakes
MAE and MSE treat being 10 minutes early the same as being 10 minutes late. In this invented courier scenario, arriving late leaves a customer waiting, while arriving early may be less costly.
A measured target can be a proxy
A proxy target is a measurable stand-in for the real goal. Minimizing prediction error on watch-time, for example, could still recommend content that frustrates viewers.
Past data vs. new conditions
A model can score well on familiar routes yet do poorly on new routes, seasons, or groups not well represented in its examples.
Consider a fictional hospital scheduling operating rooms: predicting that a surgery will finish 20 minutes sooner than it actually does can delay every patient after it, whereas leaving a 20-minute buffer causes far less disruption. Equal numeric error does not mean equal real-world harm.

Limits and quick questions.
Keep three practical limits in mind whenever you read a loss score:
- Averages hide individual failures: One low average loss can still mask terrible predictions on a small but critical group of cases.
- The known values may be off: If recorded targets are noisy or biased, minimizing loss can reproduce those flaws.
- A training score is not a real-world check: A training loss is the score on examples used while a model learns. Teams also check separate examples and the effects of mistakes before relying on a model.
- Is zero loss always the goal?
No. Outcomes can include unpredictable events like a bridge closure. A zero training loss can reflect details of those examples that do not hold on new trips. This is called overfitting; the next lesson explores it further.
- Can you compare an MAE of 4.4 directly to an MSE of 52.8?
No. MAE is measured in the original units (minutes), while MSE is measured in squared units (minutes²). Compare candidate models using the same loss function on the same dataset.
- If low loss does not prove usefulness, why train with it at all?
Training algorithms need a fast, computable score to adjust model settings step by step. Loss serves as the training compass, while real-world evaluation checks whether the destination is actually helpful.
Check your understanding.
Take this with you.
Loss is a training compass, not the final verdict. A loss function turns prediction errors from examples into one score—and choices like MAE vs. MSE decide how heavily outliers pull the model. Check real-world costs, whether the scored target matches the goal, and new examples before calling a low-loss model useful.
Ready to continue? Return to Data and Evaluation.