g↗genai/ learner
How Machines Learn / Lesson 03

Classification: choosing categories

Sorting messages into categories is not a sure-thing guess. Many spam filters rate each email with a number first, then use a cutoff rule to pick the final category.

Concept + interactive labBeginner friendly

Why many classifiers start with a score.

In Lesson 4.2, regression estimated a number such as a price. Classification is supervised learning that chooses a category (also called a class) from a fixed set of options, such as sorting an email into Spam or Inbox.

In this lesson, you will follow six terms in order: classification, category, score, threshold (cutoff), false alarm, and missed spam.

A common misconception is that a classifier “knows” the true category. While some classifiers output a label directly, many first compute a numeric score—for example, on a scale from 0.00 to 1.00, where a higher score means this filter rates the email as more spam-like based on clues it learned from labeled examples.

Even when a score looks like a percentage, a raw score of 0.66 is not automatically a 66% real-world chance of spam. Checking whether scores match real-world chances is a separate calibration step you will see in Chapter 5.

Next, a separate threshold (or cutoff) number turns that score into a label using a decision rule. In this lesson, the rule is: if an email’s score is at or above the cutoff (including an exact tie), the filter flags it as Spam; if the score is below the cutoff, the filter keeps it in Inbox.

Think of a smoke detector: its sensor measures smoke level first, and an alarm trigger level decides whether to beep. The analogy has a limit—a smoke detector measures physical smoke, whereas a spam filter only scores text clues learned from past examples.

Running example: Sam’s small bookstore inbox

Sam (an invented shop owner for this lesson) receives six emails with illustrative spam scores. To see when the filter makes a mistake, we compare the filter’s decision (Inbox or Spam) against Sam’s own judgment—called the reference label (Wanted or Spam).

Three-band diagram titled From score to category with subtitle A classifier scores an email, then a cutoff picks the label. Left to right in the middle band: Email FLASH SALE: 30% off novels goes to Classifier, producing Score: 0.66, which enters Cutoff: 0.50 showing 0.66 is at or above 0.50 and outputs Decision: Spam. Bottom left Analogy card shows a smoke detector: Like a smoke detector checking smoke level against an alarm trigger. Bottom right Key takeaways card lists: The model outputs a score, not the true class; A cutoff turns that score into a label; The score stays fixed if the cutoff moves.
In this filter, the model outputs a score first and the cutoff rule turns that score into a category decision.

How a cutoff turns a score into a category.

Because the model does not know Sam’s true intent, a cutoff can produce two kinds of mistakes:

  • False alarm: a Wanted email scores at or above the cutoff and gets flagged as Spam.
  • Missed spam: a Spam email scores below the cutoff and slips into Inbox.

Look at what happens on Sam’s six invented emails when we apply the same fixed scores at two different cutoffs. Two borderline emails explain why mistakes happen: Sam signed up for the publisher’s 0.66 flash-sale offer (so Sam labels it Wanted), while the calm 0.52 website-listing message is an unsolicited sales pitch Sam considers Spam.

At cutoff 0.50

Four emails score 0.50 or higher (0.94, 0.80, 0.66, 0.52) and are flagged as Spam. Two emails (0.26, 0.10) stay in Inbox.

Result: 1 false alarm (the 0.66 publisher promo) and 0 missed spam.

At cutoff 0.75

Only two emails score 0.75 or higher (0.94, 0.80) and are flagged as Spam. Four emails (0.66, 0.52, 0.26, 0.10) stay in Inbox.

Result: 0 false alarms, and 1 missed spam (the 0.52 unsolicited sales pitch).

Notice why no single cutoff can get all six right: the wanted 0.66 publisher promo scored higher than the 0.52 spam pitch. Because those scores overlap, people choose the cutoff based on which mistake hurts less—not because one number is magic.

Outside email, an airport metal detector works the same way when screening for prohibited items. Turning sensitivity higher catches more metal objects, but everyday belt buckles and keys trigger more false alarms.

Moving the cutoff trades one mistake for another.

On a fixed set of scores, moving the cutoff moves the boundary line without changing any email’s score:

  • Lowering the cutoff flags the same or more emails as Spam. Missed spam stays the same or drops, while false alarms stay the same or rise.
  • Raising the cutoff flags the same or fewer emails as Spam. False alarms stay the same or drop, while missed spam stays the same or rises.

A count can stay flat when no email scores at or above the lower cutoff and below the higher cutoff. For example, on Sam’s six emails, moving from 0.50 to 0.60 leaves false alarms at 1, because the 0.66 promo is still at or above both cutoffs.

Different jobs call for different cutoffs. Sam prefers a higher cutoff like 0.75 so real customer orders and publisher offers are not buried in Spam, accepting an occasional spam email in the inbox. By contrast, a bank fraud alert may use a lower cutoff so suspicious charges are flagged for a human check.

Three-band diagram titled Moving the cutoff trades mistakes with subtitle Scores stay fixed while the cutoff line shifts. Middle band shows two aligned 0.0 to 1.0 score tracks with the same six fixed dots: top track Low cutoff: 0.20 has shaded Filter: Spam at or above cutoff on the right and marks 0.66 (Sam: Wanted) as False alarm; bottom track High cutoff: 0.75 shifts the cutoff line right and marks 0.52 (Sam: Spam) as Missed spam. Bottom left Analogy card shows a metal detector: Like a metal detector for prohibited items: higher sensitivity catches more, with more false alarms. Bottom right Key takeaways card lists: Lower cutoff: same or less missed spam, same or more false alarms; Higher cutoff: same or fewer false alarms, same or more missed spam; Pick the cutoff for the mistake that costs more.
The email scores do not move—only the cutoff line shifts left or right, keeping or trading false alarms against missed spam.

Try it: move the spam cutoff on Sam’s inbox.

Every email’s score stays fixed while you drag the slider. Watch how the vertical cutoff line crosses each score bar and flips the filter’s decision.

  1. Start at Default (0.50) and find the 0.66 publisher promo marked False alarm.
  2. Click Flag less (0.75) and notice that false alarms drop to 0 while the 0.52 sales pitch becomes Missed spam.
  3. Click Flag more (0.20) and see how flagging more emails catches all spam but causes 2 false alarms (the 0.66 publisher promo and the 0.26 customer question).
  4. Drag the slider across 0.50 to 0.70 and watch the 0.66 wanted promo and 0.52 spam pitch show why no cutoff gets zero mistakes, then click Reset to 0.50.

Sam’s bookstore spam cutoff

0.50
Quick cutoffs
Flagged as Spam4
Kept in Inbox2
False alarms1
Missed spam0

Cutoff 0.50 catches all 3 spam emails, but causes 1 false alarm on wanted mail.

  • “Win a FREE cruise today!!!”Score 0.94

    Mass giveaway scam.

    Sam’s label: SpamFilter: SpamMatch
  • “Urgent: verify your bank password now”Score 0.80

    Fake bank message trying to steal a password.

    Sam’s label: SpamFilter: SpamMatch
  • “FLASH SALE: 30% off mystery novels this weekend”Score 0.66

    Real publisher offer Sam signed up for.

    Sam’s label: WantedFilter: SpamFalse alarm
  • “Quick question about your website listing”Score 0.52

    Unsolicited sales pitch Sam considers spam.

    Sam’s label: SpamFilter: SpamMatch
  • “Can you hold 2 copies of the new cookbook?”Score 0.26

    Customer order question.

    Sam’s label: WantedFilter: InboxMatch
  • “Invoice #412 for Tuesday's book delivery”Score 0.10

    Regular supplier invoice.

    Sam’s label: WantedFilter: InboxMatch

Illustrative example: these six emails and fixed spam scores are invented for this lesson so you can see how moving the cutoff changes decisions without changing the model.

What a score does—and does not—mean.

A high score means this filter rated the email as strongly spam-like based on clues learned from labeled examples—not that it checked the sender’s real intent. When real messages borrow spam-like words (“FLASH SALE”) or spam borrows polite wording, scores overlap and mistakes follow.

Classification also extends beyond two categories. A bookstore support classifier might score three categories—Order, Return, and General question—and typically pick the highest-scoring label, or route low-scoring messages to a person.

  • Is 0.50 always the best cutoff?

    No. 0.50 is a common starting point, not a universal rule. Teams choose a cutoff based on which mistake costs more in their setting.

  • Does moving the cutoff retrain the model?

    No. The model and its scores stay unchanged. Moving the cutoff only changes the decision rule applied to those scores.

  • How is classification different from regression (Lesson 4.2)?

    Regression estimates a continuous number, like a house price or temperature. Classification chooses a label from a fixed set of categories, often using scores and a decision rule.

✎ Try it yourselfKnowledge check · Practice only

Check your understanding.

In a separate invented batch of scored emails, Sam’s spam filter gives a customer’s order email (which Sam labels Wanted) a spam score of 0.64. At the 0.50 cutoff (scores 0.50 or higher are flagged as Spam), the filter flags it as Spam. Without retraining the model, Sam raises the cutoff to 0.75 and reapplies the rule to this email and the rest of the same batch. What happens?

Take this with you.

Many classifiers score first; a cutoff decides. A model does not know the true category—in score-based filters, it outputs a score and a separate cutoff rule turns that score into a label. Moving the cutoff on a fixed batch does not change the scores; it can only keep or trade false alarms against missed cases so you can match the decision to what matters most.

Ready to continue? Return to How Machines Learn.