Rademacher complexity

In computational learning theory (machine learning and theory of computation), Rademacher complexity, named after Hans Rademacher, measures richness of a class of sets with respect to a probability distribution. The concept can also be extended to real valued functions.

Rademacher complexity of a set
Given a set $$A\subseteq \mathbb{R}^m$$, the Rademacher complexity of A is defined as follows:

\operatorname{Rad}(A)

\frac{1}{m} \mathbb{E}_\sigma \left[ \sup_{a \in A}     \sum_{i=1}^m \sigma_i a_i \right] $$

where $$\sigma_1, \sigma_2, \dots, \sigma_m$$ are independent random variables drawn from the Rademacher distribution i.e. $$\Pr(\sigma_i = +1) = \Pr(\sigma_i = -1) = 1/2$$ for $$i=1,2,\dots,m$$, and $$ a=(a_1, \ldots, a_m)$$. Some authors take the absolute value of the sum before taking the supremum, but if $$A$$ is symmetric this makes no difference.

Rademacher complexity of a function class
Let $$S=\{z_1, z_2, \dots, z_m\} \subset Z$$ be a sample of points and consider a function class $$\mathcal{F}$$ of real-valued functions over $$Z$$. Then, the empirical Rademacher complexity of $$\mathcal{F}$$ given $$S$$ is defined as:

\operatorname{Rad}_S(\mathcal{F}) = \frac{1}{m} \mathbb{E}_\sigma \left[ \sup_{f \in \mathcal{F}} \sum_{i=1}^m \sigma_i f(z_i) \right] $$

This can also be written using the previous definition:
 * $$\operatorname{Rad}_S(\mathcal{F}) = \operatorname{Rad}(\mathcal{F} \circ S) $$

where $$\mathcal{F} \circ S$$ denotes function composition, i.e.:
 * $$\mathcal{F} \circ S := \{ (f(z_1),\ldots,f(z_m))\mid f\in \mathcal{F}\}$$

Let $$P$$ be a probability distribution over $$Z$$. The Rademacher complexity of the function class $$\mathcal{F}$$ with respect to $$P$$ for sample size $$m$$ is:



\operatorname{Rad}_{P,m}(\mathcal{F})

\mathbb{E}_{S\sim P^m} \left[ \operatorname{Rad}_S(\mathcal{F}) \right] $$

where the above expectation is taken over an identically independently distributed (i.i.d.) sample $$S=(z_1, z_2, \dots, z_m)$$ generated according to $$P$$.

Intuition
The Rademacher complexity is typically applied on a function class of models that are used for classification, with the goal of measuring their ability to classify points drawn from a probability space under arbitrary labellings. When the function class is rich enough, it contains functions that can appropriately adapt for each arrangement of labels, simulated by the random draw of $$\sigma_i$$ under the expectation, so that this quantity in the sum is maximised.

Examples
1. $$A$$ contains a single vector, e.g., $$A = \{(a,b)\} \subset \mathbb{R}^2$$. Then:
 * $$\operatorname{Rad}(A) = {1\over 2}\cdot \left({1\over 4}\cdot(a+b) + {1\over 4}\cdot(a-b) + {1\over 4}\cdot(-a+b) + {1\over 4}\cdot(-a-b)\right) = 0$$

The same is true for every singleton hypothesis class.

2. $$A$$ contains two vectors, e.g., $$A = \{(1,1),(1,2)\} \subset \mathbb{R}^2$$. Then:

\begin{align} \operatorname{Rad}(A) & = {1\over 2}\cdot \left({1\over 4}\cdot\max(1+1, 1+2) + {1\over 4}\cdot\max(1-1, 1-2) + {1\over 4} \cdot \max(-1+1, -1+2) + {1\over 4}\cdot\max(-1-1, -1-2)\right) \\[5pt] & = {1\over 8}(3+0+1-2) = {1\over 4} \end{align} $$

Using the Rademacher complexity
The Rademacher complexity can be used to derive data-dependent upper-bounds on the learnability of function classes. Intuitively, a function-class with smaller Rademacher complexity is easier to learn.

Bounding the representativeness
In machine learning, it is desired to have a training set that represents the true distribution of some sample data $$S$$. This can be quantified using the notion of representativeness. Denote by $$P$$ the probability distribution from which the samples are drawn. Denote by $$H$$ the set of hypotheses (potential classifiers) and denote by $$F$$ the corresponding set of error functions, i.e., for every hypothesis $$h\in H$$, there is a function $$f_h\in F$$, that maps each training sample (features,label) to the error of the classifier $$h$$ (note in this case hypothesis and classifier are used interchangeably). For example, in the case that $$h$$ represents a binary classifier, the error function is a 0–1 loss function, i.e. the error function $$f_h$$ returns 0 if $$h$$ correctly classifies a sample and 1 else. We omit the index and write $$f$$ instead of $$f_h$$ when the underlying hypothesis is irrelevant. Define:
 * $$L_P(f) := \mathbb E_{z\sim P}[f(z)]$$ – the expected error of some error function $$f\in F$$ on the real distribution $$P$$;
 * $$L_S(f) := {1\over m} \sum_{i=1}^m f(z_i)$$ – the estimated error of some error function $$f\in F$$ on the sample $$S$$.

The representativeness of the sample $$S$$, with respect to $$P$$ and $$F$$, is defined as:
 * $$ \operatorname{Rep}_P(F,S) := \sup_{f\in F} (L_P(f) - L_S(f))$$

Smaller representativeness is better, since it provides a way to avoid overfitting: it means that the true error of a classifier is not much higher than its estimated error, and so selecting a classifier that has low estimated error will ensure that the true error is also low. Note however that the concept of representativeness is relative and hence can not be compared across distinct samples.

The expected representativeness of a sample can be bounded above by the Rademacher complexity of the function class:
 * $$ \mathbb E_{S\sim P^m} [\operatorname{Rep}_P(F,S)] \leq 2 \cdot \mathbb E_{S\sim P^m} [\operatorname{Rad}(F\circ S)]$$

Bounding the generalization error
When the Rademacher complexity is small, it is possible to learn the hypothesis class H using empirical risk minimization.

For example, (with binary error function), for every $$\delta>0$$, with probability at least $$1-\delta$$, for every hypothesis $$h\in H$$:
 * $$L_P(h) - L_S(h) \leq 2 \operatorname{Rad}(F\circ S) + 4 \sqrt{2\ln(4/\delta)\over m}$$

Bounding the Rademacher complexity
Since smaller Rademacher complexity is better, it is useful to have upper bounds on the Rademacher complexity of various function sets. The following rules can be used to upper-bound the Rademacher complexity of a set $$A \subset \mathbb{R}^m$$.

1. If all vectors in $$A$$ are translated by a constant vector $$a_0 \in \mathbb{R}^m$$, then Rad(A) does not change.

2. If all vectors in $$A$$ are multiplied by a scalar $$c\in \mathbb{R}$$, then Rad(A) is multiplied by $$|c|$$.

3. $$ \operatorname{Rad}(A+B) = \operatorname{Rad}(A) + \operatorname{Rad}(B)$$.

4. (Kakade & Tewari Lemma) If all vectors in $$A$$ are operated by a Lipschitz function, then Rad(A) is (at most) multiplied by the Lipschitz constant of the function. In particular, if all vectors in $$A$$ are operated by a contraction mapping, then Rad(A) strictly decreases.

5. The Rademacher complexity of the convex hull of $$A$$ equals Rad(A).

6. (Massart Lemma) The Rademacher complexity of a finite set grows logarithmically with the set size. Formally, let $$A$$ be a set of $$N$$ vectors in $$\mathbb{R}^m$$, and let $$\bar{a}$$ be the mean of the vectors in $$A$$. Then:
 * $$\operatorname{Rad}(A) \leq \max_{a\in A} \|a-\bar{a}\| \cdot {\sqrt{2\log N}\over m}$$

In particular, if $$A$$ is a set of binary vectors, the norm is at most $$\sqrt{m}$$, so:
 * $$\operatorname{Rad}(A) \leq \sqrt{2\log N \over m} $$

Bounds related to the VC dimension
Let $$H$$ be a set family whose VC dimension  is $$d$$. It is known that the growth function of $$H$$ is bounded as:
 * for all $$m>d+1$$: $$\operatorname{Growth}(H,m)\leq (em/d)^d$$

This means that, for every set $$h$$ with at most $$m$$ elements, $$|H\cap h|\leq (em/d)^d$$. The set-family $$H\cap h$$ can be considered as a set of binary vectors over $$\mathbb{R}^m$$. Substituting this in Massart's lemma gives:
 * $$\operatorname{Rad}(H\cap h) \leq {\sqrt{2 d \log(em/d) \over m}}$$

With more advanced techniques (Dudley's entropy bound and Haussler's upper bound ) one can show, for example, that there exists a constant $$C$$, such that any class of $$\{0,1\}$$-indicator functions with Vapnik–Chervonenkis dimension $$d$$ has Rademacher complexity upper-bounded by $$C\sqrt{\frac{d}{m}}$$.

Bounds related to linear classes
The following bounds are related to linear operations on $$S$$ – a constant set of $$m$$ vectors in $$\mathbb{R}^n$$.

1. Define $$A_2 = \{(w\cdot x_1,\ldots,w\cdot x_m) \mid \|w\|_2\leq 1\} = $$ the set of dot-products of the vectors in $$S$$ with vectors in the unit ball. Then:
 * $$\operatorname{Rad}(A_2) \leq {\max_i\|x_i\|_2 \over \sqrt{m}}$$

2. Define $$A_1 = \{(w\cdot x_1,\ldots,w\cdot x_m) \mid \|w\|_1\leq 1\} = $$ the set of dot-products of the vectors in $$S$$ with vectors in the unit ball of the 1-norm. Then:
 * $$\operatorname{Rad}(A_1) \leq \max_i\|x_i\|_\infty\cdot \sqrt{2\log(2n) \over m}$$

Bounds related to covering numbers
The following bound relates the Rademacher complexity of a set $$A$$ to its external covering number – the number of balls of a given radius $$r$$ whose union contains $$A$$. The bound is attributed to Dudley.

Suppose $$A\subset \mathbb{R}^m$$ is a set of vectors whose length (norm) is at most $$c$$. Then, for every integer $$M>0$$:

\operatorname{Rad}(A) \leq {c\cdot 2^{-M}\over \sqrt{m}} + {6c \over m}\cdot \sum_{i=1}^M 2^{-i}\sqrt{\log\left(N^{\text{ext}}_{c\cdot 2^{-i}}(A)\right)} $$

In particular, if $$A$$ lies in a d-dimensional subspace of $$\mathbb{R}^m$$, then:
 * $$\forall r>0: N^{\text{ext}}_r(A) \leq (2 c \sqrt{d}/r)^d$$

Substituting this in the previous bound gives the following bound on the Rademacher complexity:

\operatorname{Rad}(A) \leq {6c \over m}\cdot \bigg(\sqrt{d\log(2\sqrt{d})} + 2\sqrt{d}\bigg) = O\bigg({c\sqrt{d\log(d)}\over m}\bigg) $$

Gaussian complexity
Gaussian complexity is a similar complexity with similar physical meanings, and can be obtained from the Rademacher complexity using the random variables $$g_i$$ instead of $$\sigma_i$$, where $$g_i$$ are Gaussian i.i.d. random variables with zero-mean and variance 1, i.e. $$g_i \sim \mathcal{N}(0,1)$$. Gaussian and Rademacher complexities are known to be equivalent up to logarithmic factors.

Equivalence of Rademacher and Gaussian complexity
Given a set $$A\subseteq\mathbb{R}^n$$ then it holds that :

$$\frac{G(A)}{2\sqrt{\log{n}}} \leq \text{Rad}(A) \leq \sqrt{\frac{\pi}{2}}G(A)$$

Where $$G(A)$$ is the Gaussian Complexity of A. As an example, consider the rademacher and gaussian complexities of the L1 ball. The Rademacher complexity is given by exactly 1, whereas the Gaussian complexity is on the order of $$\sqrt {\log d}$$ (which can be shown by applying known properties of suprema of a set of subgaussian random variables).