Classification is predicting which bucket something belongs in. Is this email spam? Which of 1,000 object types is in this photo? Is this card payment fraudulent? Is this review positive, negative or neutral? The answer is always one of a fixed list of classes, and the model learns to choose from labeled examples, which makes classification a form of supervised learning. When the answer is a number instead of a category, the task is regression.
Most classifiers output more than a label. They produce a score for each class, usually turned into probabilities with softmax, and the predicted label is the most likely one. The probabilities are useful in their own right: a fraud system might block a payment at 99% and send one at 55% to a person to review.
The kinds
- Binary: two classes, such as spam or not spam. The model outputs one probability and you choose the threshold.
- Multi-class: exactly one of many classes, such as which handwritten digit or which species of bird.
- Multi-label: any number of classes at once. A news article can be about both politics and sport.
Almost any model can classify: logistic regression, decision trees, support vector machines, and neural networks, including language models used for text classification. Each learns a decision boundary, the line or surface in the space of inputs that separates one class from another.
Measuring it honestly
Accuracy, the share of predictions that are right, is the obvious metric and often the wrong one. If 1 payment in 1,000 is fraud, a model that always answers “not fraud” is 99.9% accurate and useless. A confusion matrix breaks results down by class. Precision asks how many of the flagged cases were real; recall asks how many of the real cases were flagged. Moving the threshold trades one for the other, and the right balance depends on which mistake costs more.
The catch
Labels come from people, and people disagree, make mistakes and draw category lines differently, so a classifier inherits that noise. A classifier also has no “none of the above” unless you give it one. Shown something outside all its classes, it will still pick one, often confidently.