Test on labelled examples the model did not train on. Call spam the positive class. For a chosen threshold, the confusion matrix counts predictions against actual labels. A false positive ( is a good message incorrectly flagged as spam. A false negative ( is spam that gets through. The correct predictions are true positives ( and true negatives (
Accuracy counts all correct predictions: where is the total number of examples. If spam is rare, accuracy can look high even when the filter catches no spam.
- Precision is of the messages you flagged, how many were spam?
- Recall is of the spam messages, how many did you flag?
- False positive rate is of the good messages, how many did you flag?
If you want one number that is high only when both precision and recall are high, use their harmonic mean when both are defined. A rate with a zero denominator is undefined.
Lowering the threshold flags more messages (or leaves the predictions unchanged). Recall cannot go down, but neither can the false positive rate. An ROC curve plots recall against false positive rate as the threshold changes. Its area (ROC AUC) measures how well the scores rank positives above negatives; it does not tell you which threshold to use. Pick the threshold on validation data according to which mistakes matter, then measure performance on a separate test set.