The model and the days 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out The curve learned by logistic regression and the 16 days. The red circles at the top are days when the ice cream really sold out, the blue squares at the bottom days when it did not.
The threshold 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out The threshold is 0.50: a day with at least this probability counts as sold out. In temperature this means right of 23.39 degrees. Drag the vertical line to change the threshold.
True positives 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 Top right: said to sell out, and it did. 7 days.
False positives 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 FP 1 Bottom right: said to sell out, but it did not. The seller prepared too much for nothing. 1 days.
False negatives 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 FP 1 FN 1 Top left: said not to sell out, but it did. Customers went home empty-handed. 1 days.
True negatives 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 FP 1 FN 1 TN 7 Bottom left: said not to sell out, and it did not. 7 days. These four numbers are the confusion matrix.
Accuracy 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 FP 1 FN 1 TN 7 Accuracy is the share of right predictions: (TP + TN) / all = 0.88. It misleads when classes are unbalanced: on data that is 95 percent healthy, a model calling everyone healthy is 95 percent accurate but useless.
Precision and recall 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 FP 1 FN 1 TN 7 Precision is how many of the days called sold out really sold out: TP / (TP + FP) = 0.88. Recall is how many of the sold-out days were caught: TP / (TP + FN) = 0.88.
F1 and the trade-off 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 FP 1 FN 1 TN 7 F1 is the harmonic mean of precision and recall: 0.88. Lowering the threshold raises recall and lowers precision; raising it does the opposite. Which matters more depends on the job.
Why it matters 8 12 16 20 24 28 32 36 0 0.25 0.50 0.75 1 temperature, degrees chance of selling out TP 7 FP 1 FN 1 TN 7 In cancer screening, missing a patient is costly, so recall matters. In a spam filter, sending an important email to spam is costly, so precision matters. The confusion matrix lets us talk about this choice with numbers.