From predictions to decisions: loss functions in regression
10 questions on inference and decision, loss functions, why squared loss gives the conditional mean, the median, the mode and multimodal pitfalls.
- 10 questions
- Stopwatch
- Instant feedback
Sample questions
Play now ↑Answers stay hidden. Start the quiz to play them.
Sample 1
A delivery app penalises a late or early estimate in proportion to the size of the error, with no extra penalty for large errors. Which prediction is best?
- The conditional mean
- The largest value ever seen
- The conditional median
Sample 2
For some inputs, a task has two quite different correct outputs, around 10 and around 30, and nothing in between. What goes wrong if the model predicts the conditional mean?
- It predicts about 20, a value in between that is itself unlikely or invalid
- It predicts exactly 10 every time
- It cannot be trained at all
How it works
- One question per screen. An answer is final once sent.
- You see right away whether you were right, with a short explanation.
- The stopwatch runs: on equal scores, the faster player ranks first.
- Only your best attempt counts, so replaying is never risky.
About this quiz
A weather model that says «tomorrow's rainfall is probably between 0 and 20 millimetres, most likely around 3» is doing something useful, but it hasn't told anyone what to do. A hospital that must give a patient one specific dose of a drug, a shop that must order a definite number of loaves of bread, or a delivery app that must promise a single arrival time all have to turn a spread of possibilities into one action. How should they choose? The answer depends on what a mistake costs, and that is what decision theory is about.
This quiz separates the two stages that every regression system goes through. The first, inference, uses training data to learn a predictive distribution that expresses what is known and how uncertain it is. The second, decision, uses that distribution and a loss function, a statement of how bad each kind of error is, to pick a single value. You will see that the familiar habit of predicting the average is not a law of nature but a consequence of one particular choice of loss, and that other choices lead to other answers, such as the median or the most probable value.
The quiz also clears up a frequent confusion. The squared loss used to make decisions and the sum-of-squares error used to train the model share a name and a formula but do different jobs. One shapes how a distribution is turned into a prediction, and the other is used earlier, to fit the distribution itself. You will also see the part of the error that no predictor can remove, which comes from the intrinsic variability of the world, and a warning case where predicting the average goes badly wrong: when there are several quite different valid answers.
Typical misunderstandings include assuming that the best prediction is always the average, that all losses lead to the same prediction, and that a model with a Gaussian output is suitable for any problem. Those mistakes lead to systems that are statistically tidy but practically useless. The same separation of learning a distribution from deciding what to do with it lies behind many real systems, from risk scoring to automated trading, and it is why such systems can change their decision rule without being retrained. In short, a prediction is only half of a solution, and the other half is deciding what to do with it, given what each kind of mistake costs.
The quiz suits students and practitioners who want to think clearly about what a prediction is for. No mathematics is required. There are 10 questions, each explained straight after you answer, and the quiz takes about four minutes.
Questions and answers
›How long does the quiz take?
About 3 to 4 minutes for 10 questions, at roughly 20 seconds each. An explanation appears after every answer.
›Do I need to know calculus of variations?
No. The results are explained in terms of what the best prediction turns out to be, not of how it is derived. The quiz uses everyday situations such as dosing, ordering and forecasting to make each idea concrete.
›What are the inference and decision stages?
In the inference stage, the training data are used to work out a predictive distribution, which states how likely each possible target value is for a given input. In the decision stage, that distribution is combined with a loss function to choose one specific value to act upon. Keeping the two stages apart makes it easier to change the decision rule later. Splitting the problem this way also allows the same learned distribution to be reused for several different decisions.
›What is a loss function?
It says how costly it is to predict one value when the true one is another. Squared loss, which penalises large errors heavily, is common, and absolute loss, which penalises errors in proportion to their size, is another. Because the truth isn't known beforehand, decisions are based on the average loss over all possibilities. Different applications pick different losses; for example, a shop may count ordering too few items as costlier than ordering too many.
›Which prediction minimises the squared loss?
The average of the predictive distribution, known as the conditional mean or the regression function. Under squared loss, predicting anything else increases the expected cost. This is why training a model with a sum-of-squares error leads to predictions that estimate the mean.
›What do other loss functions give?
A family of losses based on powers of the error shows how the best prediction changes with the loss: the mean, the median and the mode can each be the best answer, depending on the power. Which one is best depends on what errors cost in the application.
›What is the irreducible part of the error?
Even the best possible predictor is wrong sometimes, because the target varies for reasons the inputs don't capture. The expected squared loss therefore has a floor, equal to the average variance of the target given the inputs, which no amount of data or modelling can remove.
›When is predicting the mean a bad idea?
When the predictive distribution has several separate peaks, for example when an input can lead to two quite different valid outputs. Such cases need models that can represent several peaks, such as mixtures. A practical safeguard is to look at the shape of the predictive distribution before trusting a single number: if it has several peaks or a very long tail, an answer based on the mean deserves suspicion. Choosing the loss is a business or safety decision as much as a technical one, and it deserves to be made explicitly.