Example 1 — Train a one-number spam filter
Show the steps and the answer
Try : it labels the emails with 3, 4, 5 and 7 links as spam, so the 3-link email is wrong. 1 error.
Training means testing settings against labeled examples and counting the mistakes each one makes.
Try : spam for 4, 5 and 7; not spam for 0, 1, 2 and 3. 0 errors.
Every labeled email lands on the correct side of the threshold.
Try : the 4-link spam email is labeled not spam. 1 error.
Raising the threshold past 4 starts letting spam through, so 4 is the best fit.
Predict: , so the 6-link email is spam; , so the 2-link email is not spam.
The learned now handles emails that were never in the training set, which is the reason for training at all.
Answer: . The 6-link email is predicted spam; the 2-link email is predicted not spam.
Takeaway: The program, not a programmer, picked the 4. Different training emails could give a different , so the data shapes the rule.