60-second card
Classification models
A classifier predicts a category, often by first giving a probability and then applying a threshold.
- Logistic regression gives a probability between 0 and 1.
- With a 0.5 threshold, 0.7 → 'yes', 0.3 → 'no'.
- Other classifiers: decision trees, k-nearest neighbours, random forests.
probs = [0.9, 0.4, 0.65, 0.2]
print(["spam" if p >= 0.5 else "not spam" for p in probs])Prints
['spam', 'not spam', 'spam', 'not spam']Remember: Probability first, then a threshold decides the class.
Common mistake: Assuming 0.5 is always the right threshold. It depends on the cost of each mistake.