Binary classification

Binary classification is a machine learning task in which a model assigns each input to one of two mutually exclusive categories, such as spam or not spam.

Binary classification is the simplest kind of classification: every input gets one of two labels. Google's machine learning glossary gives the standard examples, an email filter that decides spam or not spam, and a model that reads medical symptoms and predicts whether a person has a particular disease. By convention one class is called positive, usually the thing being looked for, and the other negative. Positive does not mean good; a positive cancer screen is the bad news.

Most binary classifiers do not output a label directly. They output a score, often a probability between 0 and 1, and a classification threshold turns that score into a decision. Google's example: with a threshold of 0.8, a score of 0.9 is classed positive and 0.7 negative. The threshold is chosen by people, not learned in training, and moving it changes the balance of mistakes. A lower threshold catches more true cases but raises more false alarms.

Those two kinds of mistake rarely cost the same. A false positive in a spam filter hides a real email; a false negative lets junk through. In medical screening, missing a disease is usually far worse than an unnecessary follow-up test. That is why binary classifiers are judged with several measures, such as precision, recall and the area under the ROC curve, rather than accuracy alone, and why a model that is 99 per cent accurate can still be useless if the condition it looks for affects only 1 per cent of cases.

Many problems with more than two answers are solved by combining binary classifiers, and much of the AI in daily use is binary at heart: fraud or not, toxic or not, AI-generated or not. When a news story reports how well such a system works, the useful questions are which threshold was used and how often each kind of error occurs.

Common questions

What is binary classification in machine learning?

It is a task in which a model sorts each input into one of exactly two categories, such as fraudulent or legitimate, or spam or not spam. The model usually produces a score, and a threshold converts that score into one label or the other.

What are examples of binary classification?

Common examples include spam filtering, fraud detection, medical tests for a single condition, deciding whether a loan applicant is likely to default, and content moderation tools that flag a post as allowed or not allowed.

How is a binary classifier evaluated?

By counting the four possible outcomes: true positives, true negatives, false positives and false negatives. Measures such as precision, recall, the F1 score and the area under the ROC curve summarise these. Accuracy alone can mislead when one class is much rarer than the other.

What is the difference between binary and multi-class classification?

Binary classification has exactly two possible classes. Multi-class classification has three or more, such as identifying which of several species a flower belongs to. Some multi-class systems are built by combining several binary classifiers.

Finding more

Search for "binary classification threshold", "precision and recall" or "ROC curve explained" to understand how these models are tuned and judged. Machine learning courses from major providers and statistics references explain the measures clearly. When reading claims about a classifier's accuracy, look for the false positive and false negative rates, and for how common the positive class is in the data.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.