Logistic RegressionScoring Our Model
In the last chapter we scored lines with the mean squared error. For a model that gives chances, we use a score called log-loss (also known as binary cross-entropy). Its rule is simple: for each student, the model pays a penalty of
A model that was right and sure pays almost nothing. A model that was wrong and sure pays a lot. Drag along the curve and complete the three missions.
The Log-Loss Formula
Three students, and the chance of passing the model gave each of them (, , ):
| Student | What happened | Chance of passing | Chance given to what happened | Penalty |
|---|---|---|---|---|
| Aman | passed | 0.9 | 0.9 | 0.11 |
| Bela | passed | 0.5 | 0.5 | |
| Chirag | failed | 0.9 | 2.30 |
Chirag failed, but the model was 90 % sure he would pass — so it pays the biggest penalty. The log-loss is the average penalty:
Log-loss
For examples with true labels (1 or 0) and predicted chances ,
When only the first term survives; when only the second. That is exactly "the chance given to what really happened".
So during training, the model should
Tip
Why not use MSE again? With chances between 0 and 1, the squared error can never be bigger than 1, so a model that is 99 % sure and wrong gets off lightly. Log-loss has no upper limit: being confidently wrong is punished hard, which is exactly what we want.
Speed Round: Who Pays More?
Get five right to move on.