All labs Animated labs The chapter Course home

Lab 08Classifier threshold

A classifier does not output a decision. It outputs a score, and a threshold turns the score into a decision. Move the cut through the ranked documents below and watch every measure change at once: the four outcomes, precision, recall, and the point you are at on the ROC and precision-recall curves. The numbers come from classification.py, so they match the chapter.

Cut:

the rare class (what we are looking for) everything else. Outlined documents are the ones flagged.

The four outcomes

What to look for

  • Flag nothing, then flag the top 2. Precision is 1.000 and recall is 0.667: nothing wrong was flagged, and a rare document was missed.
  • Move to the top 4. Recall reaches 1.000 and precision drops to 0.750. Every step down the ranking buys recall at the price of precision. The threshold is a separate decision from the model.
  • Flag everything. Recall is 1.000 and precision falls to 0.300, the share of the rare class. Accuracy alone would call that a bad model, and F1 shows exactly why.
  • Switch to the rare class. The ROC curve stays near the top-left corner, ROC-AUC 0.9490, because ninety-eight negatives sit below each positive. The precision curve collapses, PR-AUC 0.2667. Under imbalance, report PR-AUC.

Where this fits

This is Text Classification, the section on thresholds. Run classification.py to print the same tables as text, or score a classifier yourself in Project 5.