Loss Functions and What They Reward
Choose a loss that matches what you actually care about, and know what each one optimises
A taste of a lesson
We forecast stock levels. Running out costs us far more than overstock. Should I still train with squared error?
Squared error treats overshooting and undershooting equally and aims at the mean, which does not match your costs. Consider quantile loss: with tau = 0.9, the model learns a level that demand exceeds only about 10 percent of the time, so you run out less often at the price of extra stock. You can choose tau from the cost ratio: if a stockout costs 9 times an extra unit, tau = 9 / (9 + 1) = 0.9. What is your rough cost of a stockout compared with holding one extra unit?
Written by the teacher as an example. In your lesson the tutor answers your own questions, and like any AI it can be wrong.
What you will be able to do
- Explain which statistic squared, absolute and quantile losses target
- Choose robust losses such as Huber when outliers are present
- Explain why log loss encourages calibrated probabilities
- Encode unequal error costs with weighted or asymmetric losses
- Check that the training loss aligns with the reported metric
Lesson plan
- 1 A loss defines good See how different losses choose different best predictions. Start
- 2 Regression losses Compare squared, absolute and Huber losses. Start
- 3 Quantile loss Predict percentiles with the pinball loss. Start
- 4 Classification losses Understand log loss, hinge loss and the Brier score. Start
- 5 Unequal costs Encode real world costs into training. Start
- 6 Loss versus metric Align what you train on with what you report. Start
Try asking
About this tutor
An intermediate tutor on the choice that quietly defines every model: the loss function. You will see that squared error targets the mean, absolute error the median and quantile loss any percentile you choose, and why log loss produces probabilities that can be trusted. Lessons cover Huber loss for outliers, hinge loss, class weighted and asymmetric losses for unequal costs, and the gap between the loss you train on and the metric you report. Exercises use small numeric examples so you can see each loss pull a prediction in a different direction.
Reviews
4.3
3 ratingsSample
- Daniela K.Sample
Good explanation of why log loss rewards calibration. Would like more on custom losses.
- Henry A.Sample
Clear connection between costs and losses. The cost ratio formula for tau was immediately useful.
- Samira T.Sample
The 1, 2, 3, 4, 20 example showed in five minutes why our forecasts were skewed by a few huge orders. Quantile loss fixed our stockouts.
About the teacher
Calculus and optimisation for machine learning, done by hand
9 tutors 319 lessons taught Sample
I teach the calculus and optimisation that make models learn: derivatives, gradients, the chain rule, gradient descent and the loss functions it minimises. My background is in engineering and numerical computing, so I care about why things work and also about when they break, such as unstable learning rates or overflowing exponentials. I teach with pencil calculations first, then a...
See Leandro's profile and tutorsMore like this
Other tutors on the same or nearby topics.