Empirical risk minimization is a principle in statistical learning theory which defines a family of learning algorithms based on evaluating performance over a known and fixed dataset. The core idea is based on an application of the law of large numbers; more specifically, we cannot know exactly how well a predictive algorithm will work in practice (i.e. the true "risk") because we don't know the true distribution of the data, but we can instead estimate and optimize the performance of the algorithm on a known set of training data. The performance over the known set of training data is referred to as the empirical risk.

## Background

Consider the following situation, which is a general setting of many supervised learning problems. We have two spaces of objects ${\displaystyle X}$ and ${\displaystyle Y}$ and would like to learn a function ${\displaystyle \ h:X\to Y}$ (often called hypothesis) which outputs an object ${\displaystyle y\in Y}$, given ${\displaystyle x\in X}$. To do so, we have at our disposal a training set of ${\displaystyle n}$ examples ${\displaystyle \ (x_{1},y_{1}),\ldots ,(x_{n},y_{n})}$ where ${\displaystyle x_{i}\in X}$ is an input and ${\displaystyle y_{i}\in Y}$ is the corresponding response that we wish to get from ${\displaystyle h(x_{i})}$.

To put it more formally, we assume that there is a joint probability distribution ${\displaystyle P(x,y)}$ over ${\displaystyle X}$ and ${\displaystyle Y}$, and that the training set consists of ${\displaystyle n}$ instances ${\displaystyle \ (x_{1},y_{1}),\ldots ,(x_{n},y_{n})}$ drawn i.i.d. from ${\displaystyle P(x,y)}$. Note that the assumption of a joint probability distribution allows us to model uncertainty in predictions (e.g. from noise in data) because ${\displaystyle y}$ is not a deterministic function of ${\displaystyle x}$, but rather a random variable with conditional distribution ${\displaystyle P(y|x)}$ for a fixed ${\displaystyle x}$.

We also assume that we are given a non-negative real-valued loss function ${\displaystyle L({\hat {y)),y)}$ which measures how different the prediction ${\displaystyle {\hat {y))}$ of a hypothesis is from the true outcome ${\displaystyle y}$. For classification tasks these loss functions can be scoring rules. The risk associated with hypothesis ${\displaystyle h(x)}$ is then defined as the expectation of the loss function:

${\displaystyle R(h)=\mathbf {E} [L(h(x),y)]=\int L(h(x),y)\,dP(x,y).}$

A loss function commonly used in theory is the 0-1 loss function: ${\displaystyle L({\hat {y)),y)={\begin{cases}1&{\mbox{ if ))\quad {\hat {y))\neq y\\0&{\mbox{ if ))\quad {\hat {y))=y\end{cases))}$.

The ultimate goal of a learning algorithm is to find a hypothesis ${\displaystyle h^{*))$ among a fixed class of functions ${\displaystyle {\mathcal {H))}$ for which the risk ${\displaystyle R(h)}$ is minimal:

${\displaystyle h^{*}={\underset {h\in {\mathcal {H))}{\operatorname {arg\,min} ))\,{R(h)}.}$

For classification problems, the Bayes classifier is defined to be the classifier minimizing the risk defined with the 0–1 loss function.

## Empirical risk minimization

In general, the risk ${\displaystyle R(h)}$ cannot be computed because the distribution ${\displaystyle P(x,y)}$ is unknown to the learning algorithm (this situation is referred to as agnostic learning[citation needed]). However, given a sample of iid training data points, we can compute an estimate, called the empirical risk, by computing the average of the loss function over the training set; more formally, computing the expectation with respect to the empirical measure:

${\displaystyle \!R_{\text{emp))(h)={\frac {1}{n))\sum _{i=1}^{n}L(h(x_{i}),y_{i}).}$

The empirical risk minimization principle[1] states that the learning algorithm should choose a hypothesis ${\displaystyle {\hat {h))}$ which minimizes the empirical risk over the hypothesis class ${\displaystyle {\mathcal {H))}$:

${\displaystyle {\hat {h))={\underset {h\in {\mathcal {H))}{\operatorname {arg\,min} ))\,R_{\text{emp))(h).}$

Thus, the learning algorithm defined by the empirical risk minimization principle consists in solving the above optimization problem.

## Properties

This section needs expansion. You can help by adding to it. (February 2023)

Guarantees for the performance of empirical risk minimization depend strongly on the function class selected as well as the distributional assumptions made.[2] In general, distribution-free methods are too coarse, and do not lead to practical bounds. However, they are still useful in deriving asymptotic properties of learning algorithms, such as consistency. In particular, distribution-free bounds on the performance of empirical risk minimization given a fixed function class can be derived using bounds on the VC complexity of the function class.

For simplicity, considering the case of binary classification tasks, it is possible to bound the probability of the selected classifier, ${\displaystyle \phi _{n))$ being much worse than the best possible classifier ${\displaystyle \phi ^{*))$. Consider the risk ${\displaystyle L}$ defined over the hypothesis class ${\displaystyle {\mathcal {C))}$ with growth function ${\displaystyle {\mathcal {S))({\mathcal {C)),n)}$ given a dataset of size ${\displaystyle n}$. Then, for every ${\displaystyle \epsilon >0}$:[3]

${\displaystyle \mathbb {P} \left(L(\phi _{n})-L(\phi ^{*})\right)\leq {\mathcal {8))S({\mathcal {C)),n)\exp\{-n\epsilon ^{2}/32\))$

Similar results hold for regression tasks.[2] These results are often based on uniform laws of large numbers, which control the deviation of the empirical risk from the true risk, uniformly over the hypothesis class.[3]

### Imposibility results

It is also possible to show lower bounds on algorithm performance if no distributional assumptions are made.[4] This is sometimes referred to as the No free lunch theorem. Even though a specific learning algorithm may provide the asymptotically optimal performance for any distribution, the finite sample performance is always poor for at least one data distribution. This means that no classifier can provide on the error for a given sample size for all distributions.[3]

Specifically, Let ${\displaystyle \epsilon >0}$ and consider a sample size ${\displaystyle n}$ and classification rule ${\displaystyle \phi _{n))$, there exists a distribution of ${\displaystyle (X,Y)}$ with risk ${\displaystyle L^{*}=0}$ (meaning that perfect prediction is possible) such that:[3]

${\displaystyle \mathbb {E} L_{n}\geq 1/2-\epsilon .}$

It's further possible to show that the convergence rate of a learning algorithm is poor for some distributions. Specifically, given a sequence of decreasing positive numbers ${\displaystyle a_{i))$ converging to zero, it is possible to find a distribution such that:

${\displaystyle \mathbb {E} L_{n}\geq a_{i))$

for all ${\displaystyle n}$. This result shows that universally good classification rules do not exist, in the sense that the rule must be low quality for at least one distribution.[3]

### Computational complexity

Empirical risk minimization for a classification problem with a 0-1 loss function is known to be an NP-hard problem even for a relatively simple class of functions such as linear classifiers.[5] Nevertheless, it can be solved efficiently when the minimal empirical risk is zero, i.e., data is linearly separable.[citation needed]

In practice, machine learning algorithms cope with this issue either by employing a convex approximation to the 0–1 loss function (like hinge loss for SVM), which is easier to optimize, or by imposing assumptions on the distribution ${\displaystyle P(x,y)}$ (and thus stop being agnostic learning algorithms to which the above result applies).

In the case of convexification, Zhang's lemma majors the excess risk of the original problem using the excess risk of the convexified problem.[6] Minimizing the later using convex optimization also allow to control the former.

## Tilted empirical risk minimization

Tilted empirical risk minimization is a machine learning technique used to modify standard loss functions like Squared Error by introducing a tilt parameter. This parameter dynamically adjusts the weight of data points during training, allowing the algorithm to focus on specific regions or characteristics of the data distribution. Tilted empirical risk minimization is particularly useful in scenarios with imbalanced data or when there is a need to emphasize errors in certain parts of the prediction space.