Binary classification refers to machine learning models trained for tasks with exactly two class labels. In general, one label is treated as the positive class and the other as the negative class: fraud vs not fraud, spam vs not spam, defect vs no defect. The model learns a decision boundary that separates the two outcomes on input features.
Most production ML guardrails, dashboards, and compliance reviews still assume a binary frame even when the underlying product is more complex. If you ship scoring systems, you need fluent control of thresholds, confusion-matrix metrics, and the gap between a probability and a hard label.
Build better agents with Arize
Trace, evaluate, and learn. Build agents that work with Arize AX and start tracing your runs today.
Prefer open source? Try Arize Phoenix for self-hosted, open source agent observability.
Key takeaways
- Binary classification outputs two mutually exclusive classes, often encoded as 0/1 or negative/positive.
- Many models emit a continuous score first; you apply a threshold to produce the final class label.
- Core metrics include precision, recall, specificity, F-score, and ROC or PR curves at chosen thresholds.
- Class imbalance makes accuracy misleading; inspect false positive and false negative counts directly.
- Binary framing extends to LLM routing, safety filters, and agent tool gates that choose between two actions.
Scores, thresholds, and hard labels
Training often produces more than a raw class bit. Logistic regression outputs probability. Gradient boosted trees output scores converted to probability. Neural nets may emit logits passed through a sigmoid. All of these are scores on a continuum.
Deployment applies a threshold: predict positive if score >= t, else negative. Changing t moves the tradeoff between false positives and false negatives without retraining. That separation between model artifact and policy threshold is central to binary classification in production.
Some pipelines skip explicit scores and output a label directly. You still inherit an implicit threshold inside the model. For monitoring and appeals, prefer models that expose scores so you can adjust cutoffs without redeploying weights.
Confusion matrix vocabulary
Every binary decision can be summarized with four counts:
- True positive (TP): actual positive, predicted positive.
- True negative (TN): actual negative, predicted negative.
- False positive (FP): actual negative, predicted positive (false alarm).
- False negative (FN): actual positive, predicted negative (miss).
From these, derive precision, recall, specificity, and F-scores. Name sibling concepts in prose when you need deeper definitions: false positive rate pairs with specificity; recall is sensitivity on the positive class.
When stakeholders ask “how accurate is the model,” answer with the metric tied to their cost model. Accuracy alone hides pain when negatives dominate.
Choosing metrics and thresholds
Binary classification rarely optimizes a single number. Typical patterns:
- High recall when missing a positive is expensive (disease screening, critical fraud).
- High precision when false alarms waste human review capacity.
- High specificity when falsely flagging negatives creates user harm or operational load.
Plot ROC when both classes matter roughly equally in aggregate ranking. Plot precision-recall when positives are rare. Mark the deployed threshold on the curve and store confusion counts at that point.
Teams shipping image classification models with confidence often keep PR curves for imbalanced vision tasks and document why the production threshold beat alternatives.
Training data and label definition
Binary models are only as stable as the label rule. “Churn in 30 days” and “churn in 90 days” are different binaries. “Spam” definitions drift as adversaries adapt. Freeze label specifications in model cards and revisit them when retraining.
Watch for label leakage: features available only after the decision moment creep into training and inflate offline metrics. Time-based splits and point-in-time feature joins prevent fake binary performance.
For LLM-assisted labeling, treat judge disagreement as part of the binary noise floor. Evaluate on adjudicated subsets when automating labels at scale.
Binary classification beyond tabular ML
Modern systems reuse binary framing in new stacks:
- LLM safety classifiers block vs allow.
- Intent routers send to agent A vs default path.
- Retrieval gates fetch vs answer from parametric knowledge.
- Agent tool approval execute vs refuse.
The surface is generative; the evaluation metric is often still binary on the action taken. LLM and agent evaluation platforms unify classical binary metrics with judge-based labels when human review defines positive and negative outcomes on trajectories.
Binary vs multi-class and multilabel
Multi-class chooses one label among three or more (cat, dog, bird). Softmax outputs are mutually exclusive. You can reduce multi-class to one-vs-rest binary problems for per-class metrics.
Multilabel allows multiple positives at once (tags on a document). Each label is its own binary subproblem with independent thresholds.
Do not treat a multi-class argmax as a single binary without defining which class is “positive” for the metric you report.
Monitoring binary models in production
Track score distributions, calibration, and confusion-derived rates on labeled audit samples. Alert on population shifts that change precision at a fixed threshold even when weights are frozen.
Fold binary models into AI model lifecycle management: version thresholds with model versions, revalidate after feature pipeline changes, and compare challenger models on the same binary eval split before canary.
When labels arrive late (fraud confirmed days later), use proxy metrics short term but backfill confusion counts when ground truth matures.
FAQ
What is the positive class in binary classification?
It is the class you care about detecting or the event labeled 1 in training. Convention varies by domain: fraud, disease, click. Document which label is positive in every report and API schema.
Can a binary classifier output probabilities?
Yes. Most production binary models output a score or probability for the positive class. The hard label comes from comparing that score to a threshold.
Why is my accurate binary model useless in production?
Likely class imbalance, a threshold tuned on the wrong metric, label drift, or leakage in offline eval. Inspect FP and FN counts at the deployed threshold on recent data.
How does binary classification relate to logistic regression?
Logistic regression is a classic binary classifier that models P(positive | features) with a sigmoid. Many other algorithms (SVM, trees, neural nets) also solve binary tasks with different score functions.
Should I always use 0.5 as the threshold?
No. 0.5 is only sensible when classes are balanced and false positives and false negatives have equal cost. Tune thresholds on validation data against business constraints.