Dictionary of Applied Machine Learning: 115 machine-learning terms, each with a definition, a figure, citations and a Python demo · All terms · Demos · Start here
Updated on 2026-11-08
Readiness 100/100
See also classification decision boundary logistic loss logistic regression accuracy confusion matrix baseline
Binary classification refers to machine learning (ML) applications with a binary label space. The goal of binary classification is to assign each data point to one of two classes, each class represented by one of the two label values. Strictly speaking, a binary classifier is a hypothesis map from the feature space to a binary label space. However, it is customary to construct such a classifier by comparing the value of a real-valued hypothesis map against a threshold. Linear classifiers are obtained from the sign of a linear hypothesis map. A binary classifier partitions the feature space into two decision regions separated by a decision boundary, which is a hyperplane for a linear classifier. The natural loss function is the $0/1$ loss, whose average over a dataset is $1$ minus the accuracy. However, this loss function is hard to optimize for training methods, and its average on imbalanced data is dominated by the majority label value, so it does not indicate which of the two kinds of mistake a classifier makes. Practical methods therefore often use other loss functions for model training and validation.

binclass.py, which recomputes what the entry states: the script block by block · open in ColabA frost warning answers one question: will the temperature in the coming night fall below $0$ degrees Celsius? The answer is yes or no, nothing in between. An email is spam or not. A credit application defaults or not. A biopsy image is malignant or benign. Binary classification is the machine learning (ML) problem behind all of these questions: predict, from the features of a data point, which of two values its label, a number $y$, takes.
Binary classification is classification with a label space $\mathcal{Y}$ that holds two elements. Each data point carries one label, and that label takes one of the two values. The two values are usually written (or encoded) as $\mathcal{Y} = \{-1, +1\}$ or $\mathcal{Y} = \{0, 1\}$. The choice of the two label values (the encoding) is a convention and irrelevant for the basic properties of binary classification methods. However, mathematical expressions about them often assume a particular encoding, such as $\{-1, +1\}$, and need to be modified accordingly if a different encoding, such as $\{0, 1\}$, is used.
Strictly speaking, a binary classifier is a hypothesis map that takes values in a binary label space $\mathcal{Y}$. It is usually built from a real-valued hypothesis map $h: \mathcal{X} \rightarrow \mathbb{R}$ by comparing its value against a threshold. For the label encoding $\mathcal{Y} = \{-1, +1\}$ and the threshold $0$, a data point is then classified by the sign, $\widehat{y} = \operatorname{sign}(h({\mathbf x}))$. The classifier partitions the feature space into two decision regions, one per label value. They are separated by the decision boundary, the set of ${\mathbf x}$ with $h({\mathbf x}) = 0$. The product $y \cdot h({\mathbf x})$ is the margin of $h$ on the data point $({\mathbf x}, y)$. It is positive exactly when the prediction is right.
B-regionsFor a linear classifier the real-valued hypothesis is
$h({\mathbf x}) = {\mathbf w}^{\top} {\mathbf x} + w_{0}$
with model parameters ${\mathbf w}$ and $w_{0}$, so the
decision boundary is the hyperplane ${\mathbf w}^{\top}
{\mathbf x} + w_{0} = 0$, a straight line when there are two
features (Bishop, 2006, Sect. 4.1.1).
The predicted label value is the side of that
hyperplane on which ${\mathbf x}$ lies, and the distance of
${\mathbf x}$ from the hyperplane is $|h({\mathbf x})|
/ \Vert {{\mathbf w}} \Vert$. A data point that lies on the side of the
other label value is misclassified. Its $0/1$ loss is
$1$ (Fig. 1).
pythondemos/binclass.py
In the frost warning of the opening, the features of a data point are the minimum and the maximum air temperature of one day. Its label is $y = +1$ if the minimum temperature of the following night falls below $0$ degrees Celsius, and $y = -1$ otherwise. A wrong $-1$ leaves a fruit grower's blossoms unprotected in a frost. A wrong $+1$ only costs one night of covering or heating them. The two mistakes are therefore not interchangeable, and the classifier is chosen so that wrong $-1$ predictions are rare.
Synonyms: two-class classification.
See also: classification, multi-label classification, classifier, decision boundary, $\bf 0/1$ loss, logistic loss, logistic regression, accuracy, confusion matrix, imbalanced data, baseline.
@misc{dictml_binclass,
author = {Jung, Alexander},
editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
title = {binary classification},
howpublished = {Dictionary of Applied Machine Learning (course edition)},
year = {2026},
doi = {10.5281/zenodo.21569296},
note = {ISBN 978-952-64-3013-3, CC BY 4.0, retrieved 2026-11-13},
url = {https://dictionaryofml.org/terms/binclass.html}
}