Dictionary of Applied Machine Learning
Updated on 2026-09-11
Typeset PDF version — the authoritative form of this entry
Python demo — a script that recomputes what this entry states and prints one line per check
Accuracy is the fraction of correct predictions made by a hypothesis on a dataset with a finite label space, equal to one minus the average $0/1$ loss. It is widely used as a single-number metric for classification methods. Accuracy is not suitable as an objective function for training, since the $0/1$ loss is non-smooth and non-convex. Empirical risk minimization (ERM) uses a smooth surrogate loss instead, and accuracy is reported during validation. On imbalanced data, a large accuracy can hide failure on the minority class, which calls for other means of evaluation such as the confusion matrix.
Accuracy is the fraction of correct predictions made by a hypothesis $\hypothesis: \featurespace \rightarrow \labelspace$ on a dataset $\dataset = \big\{ \big(\featurevec^{(\sampleidx)}, \truelabel^{(\sampleidx)} \big) \big\}_{\sampleidx=1}^{\samplesize}$ with a finite label space $\labelspace$ (Goodfellow et al., 2016, Sect. 5.1): \begin{align*} \operatorname{acc}(\hypothesis|\dataset) & \defeq 1 - \frac{1}{\samplesize} \sum_{\sampleidx=1}^{\samplesize} \lossfunczo{\big(\featurevec^{(\sampleidx)}, \truelabel^{(\sampleidx)}\big)}{\hypothesis} \\ & = \frac{1}{\samplesize} \Big| \Big\{ \sampleidx \in \{1, \,\ldots, \,\samplesize\} : \hypothesis\big(\featurevec^{(\sampleidx)}\big) = \truelabel^{(\sampleidx)} \Big\} \Big| \text{.} \end{align*} Accuracy ranges from $0$ (no prediction is correct) to $1$ (every prediction is correct). Equivalently, accuracy equals one minus the average $0/1$ loss on the dataset. For example, in image classification, accuracy is the fraction of images assigned the correct category.
S-linear-classifier-hFig. 1 compares two classifiers on the
same dataset. The linear classifier $\hypothesis$
misclassifies three data points near its
decision boundary. The nonlinear classifier
$\hypothesis'$ curves around each of these data points and
classifies them correctly.
pythondemos/accuracy.py
While accuracy is often used to compare learned
classifiers on a validation set or a test set, it is
not suitable as an objective function for training. Indeed,
accuracy is defined via the $0/1$ loss, which is
non-smooth and non-convex. Gradient-based
optimization methods cannot maximize accuracy directly. Instead,
training methods for classifiers, e.g., via
empirical risk minimization (ERM), typically use a surrogate loss that
approximates the $0/1$ loss. Two widely used examples
for such a surrogate loss are the logistic loss, which is
convex and differentiable, and the hinge loss,
which is convex but not differentiable.
Fig. 2 shows the three loss functions
for binary classification with $\labelspace = \{-1, 1\}$, where a
real-valued hypothesis $\hypothesis$ predicts via the sign
of $\hypothesis(\featurevec)$. Each loss function depends on
the data point only through the product
$\truelabel \cdot \hypothesis(\featurevec)$.
pythondemos/cm.py
@misc{dictml_accuracy,
author = {Jung, Alexander and Olioumtsevits, Konstantina and Schnoor, Ekkehard},
title = {accuracy},
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-09-11},
url = {https://dictionaryofml.org/terms/accuracy.html}
}