# Vapnik–Chervonenkis dimension

(Redirected from VC dimension)

In Vapnik–Chervonenkis theory, the Vapnik–Chervonenkis (VC) dimension is a measure of the capacity (complexity, expressive power, richness, or flexibility) of a set of functions that can be learned by a statistical binary classification algorithm. It is defined as the cardinality of the largest set of points that the algorithm can shatter. It was originally defined by Vladimir Vapnik and Alexey Chervonenkis.[1]

Informally, the capacity of a classification model is related to how complicated it can be. For example, consider the thresholding of a high-degree polynomial: if the polynomial evaluates above zero, that point is classified as positive, otherwise as negative. A high-degree polynomial can be wiggly, so it can fit a given set of training points well. But one can expect that the classifier will make errors on other points, because it is too wiggly. Such a polynomial has a high capacity. A much simpler alternative is to threshold a linear function. This function may not fit the training set well, because it has a low capacity. This notion of capacity is made rigorous below.

## Definitions

### VC dimension of a set-family

Let ${\displaystyle H}$ be a set family (a set of sets) and ${\displaystyle C}$ a set. Their intersection is defined as the following set family:

${\displaystyle H\cap C:=\{h\cap C\mid h\in H\}.}$

We say that a set ${\displaystyle C}$ is shattered by ${\displaystyle H}$ if ${\displaystyle H\cap C}$ contains all the subsets of ${\displaystyle C}$, i.e.:

${\displaystyle |H\cap C|=2^{|C|}.}$

The VC dimension ${\displaystyle D}$ of ${\displaystyle H}$ is the largest cardinality of sets shattered by ${\displaystyle H}$. If arbitrarily large subsets can be shattered, the VC dimension is ${\displaystyle \infty }$.

### VC dimension of a classification model

A binary classification model ${\displaystyle f}$ with some parameter vector ${\displaystyle \theta }$ is said to shatter a set of data points ${\displaystyle (x_{1},x_{2},\ldots ,x_{n})}$ if, for all assignments of labels to those points, there exists a ${\displaystyle \theta }$ such that the model ${\displaystyle f}$ makes no errors when evaluating that set of data points.

The VC dimension of a model ${\displaystyle f}$ is the maximum number of points that can be arranged so that ${\displaystyle f}$ shatters them. More formally, it is the maximum cardinal ${\displaystyle D}$ such that some data point set of cardinality ${\displaystyle D}$ can be shattered by ${\displaystyle f}$.

## Examples

1. ${\displaystyle f}$ is a constant classifier (with no parameters). Its VC-dimension is 0 since it cannot shatter even a single point. In general, the VC dimension of a finite classification model, which can return at most ${\displaystyle 2^{d}}$ different classifiers, is at most ${\displaystyle d}$ (this is an upper bound on the VC dimension; the Sauer–Shelah lemma gives a lower bound on the dimension).

2. ${\displaystyle f}$ is a single-parametric threshold classifier on real numbers; i.e, for a certain threshold ${\displaystyle \theta }$, the classifier ${\displaystyle f_{\theta }}$ returns 1 if the input number is larger than ${\displaystyle \theta }$ and 0 otherwise. The VC dimension of ${\displaystyle f}$ is 1 because: (a) It can shatter a single point. For every point ${\displaystyle x}$, a classifier ${\displaystyle f_{\theta }}$ labels it as 0 if ${\displaystyle \theta >x}$ and labels it as 1 if ${\displaystyle \theta . (b) It cannot shatter any set of two points. For every set of two numbers, if the smaller is labeled 1, then the larger must also be labeled 1, so not all labelings are possible.

3. ${\displaystyle f}$ is a single-parametric interval classifier on real numbers; i.e, for a certain parameter ${\displaystyle \theta }$, the classifier ${\displaystyle f_{\theta }}$ returns 1 if the input number is in the interval ${\displaystyle [\theta ,\theta +4]}$ and 0 otherwise. The VC dimension of ${\displaystyle f}$ is 2 because: (a) It can shatter some sets of two points. E.g, for every set ${\displaystyle \{x,x+2\}}$, a classifier ${\displaystyle f_{\theta }}$ labels it as (0,0) if ${\displaystyle \theta or if ${\displaystyle \theta >x+2}$, as (1,0) if ${\displaystyle \theta \in [x-4,x-2)}$, as (1,1) if ${\displaystyle \theta \in [x-2,x]}$, and as (0,1) if ${\displaystyle \theta \in (x,x+2]}$. (b) It cannot shatter any set of three points. For every set of three numbers, if the smallest and the largest are labeled 1, then the middle one must also be labeled 1, so not all labelings are possible.

4. ${\displaystyle f}$ is a straight line as a classification model on points in a two-dimensional plane (this is the model used by a perceptron). The line should separate positive data points from negative data points. There exist sets of 3 points that can indeed be shattered using this model (any 3 points that are not collinear can be shattered). However, no set of 4 points can be shattered: by Radon's theorem, any four points can be partitioned into two subsets with intersecting convex hulls, so it is not possible to separate one of these two subsets from the other. Thus, the VC dimension of this particular classifier is 3. It is important to remember that while one can choose any arrangement of points, the arrangement of those points cannot change when attempting to shatter for some label assignment. Note, only 3 of the 23 = 8 possible label assignments are shown for the three points.

 3 points shattered 4 points impossible

5. ${\displaystyle f}$ is a single-parametric sine classifier, i.e, for a certain parameter ${\displaystyle \theta }$, the classifier ${\displaystyle f_{\theta }}$ returns 1 if the input number ${\displaystyle x}$ is larger than ${\displaystyle \sin(\theta x)}$ and 0 otherwise. The VC dimension of ${\displaystyle f}$ is infinite, since it can shatter any finite subset of the set ${\displaystyle \{2^{-m}\mid m\in \mathbb {N} \}}$.[2]:57

## Uses

### In statistical learning theory

The VC dimension can predict a probabilistic upper bound on the test error of a classification model. Vapnik[3] proved that the probability of the test error (i.e., risk with 0-1 loss function) distancing from an upper bound (on data that is drawn i.i.d. from the same distribution as the training set) is given by:

${\displaystyle \Pr \left({\text{test error}}\leqslant {\text{training error}}+{\sqrt {{\frac {1}{N}}\left[D\left(\log \left({\tfrac {2N}{D}}\right)+1\right)-\log \left({\tfrac {\eta }{4}}\right)\right]}}\,\right)=1-\eta ,}$

where ${\displaystyle D}$ is the VC dimension of the classification model, ${\displaystyle 0<\eta \leqslant 1}$, and ${\displaystyle N}$ is the size of the training set (restriction: this formula is valid when ${\displaystyle D\ll N}$. When ${\displaystyle D}$ is larger, the test-error may be much higher than the training-error. This is due to overfitting).

The VC dimension also appears in sample-complexity bounds. A space of binary functions with VC dimension ${\displaystyle D}$ can be learned with:

${\displaystyle N=\Theta \left({\frac {D+\ln {1 \over \delta }}{\varepsilon }}\right)}$

samples, where ${\displaystyle \varepsilon }$ is the learning error and ${\displaystyle \delta }$ is the failure probability. Thus, the sample-complexity is a linear function of the VC dimension of the hypothesis space.

### In computational geometry

The VC dimension is one of the critical parameters in the size of ε-nets, which determines the complexity of approximation algorithms based on them; range sets without finite VC dimension may not have finite ε-nets at all.

## Bounds

0. The VC dimension of the dual set-family of ${\displaystyle {\mathcal {F}}}$ is strictly less than ${\displaystyle 2^{\operatorname {vc} ({\mathcal {F}})+1}}$, and this is best possible.

1. The VC dimension of a finite set-family ${\displaystyle H}$ is at most ${\displaystyle \log _{2}|H|}$.[2]:56 This is because ${\displaystyle |H\cap C|\leq |H|}$ by definition.

2. Given a set-family ${\displaystyle H}$, define ${\displaystyle H_{s}}$ as a set-family that contains all intersections of ${\displaystyle s}$ elements of ${\displaystyle H}$. Then:[2]:57

${\displaystyle \operatorname {VCDim} (H_{s})\leq \operatorname {VCDim} (H)\cdot (2s\log _{2}(3s))}$

3. Given a set-family ${\displaystyle H}$ and an element ${\displaystyle h_{0}\in H}$, define ${\displaystyle H\,\Delta h_{0}:=\{h\,\Delta h_{0}\mid h\in H\}}$ where ${\displaystyle \Delta }$ denotes symmetric set difference. Then:[2]:58

${\displaystyle \operatorname {VCDim} (H\,\Delta h_{0})=\operatorname {VCDim} (H)}$

## VC dimension of a finite projective plane

A finite projective plane of order n is a collection of n2 + n + 1 sets (called "lines") over n2 + n + 1 elements (called "points"), for which:

• Each line contains exactly n + 1 points.
• Each line intersects every other line in exactly one point.
• Each point is contained in exactly n + 1 lines.
• Each point is in exactly one line in common with every other point.
• At least four points do not lie in a common line.

The VC dimension of a finite projective plane is 2.[4]

Proof: (a) For each pair of distinct points, there is one line that contains both of them, lines that contain only one of them, and lines that contain none of them, so every set of size 2 is shattered. (b) For any triple of three distinct points, if there is a line x that contain all three, then there is no line y that contains exactly two (since then x and y would intersect in two points, which is contrary to the definition of a projective plane). Hence, no set of size 3 is shattered.

## VC dimension of a boosting classifier

Suppose we have a base class ${\displaystyle B}$ of simple classifiers, whose VC dimension is ${\displaystyle D}$.

We can construct a more powerful classifier by combining several different classifiers from ${\displaystyle B}$; this technique is called boosting. Formally, given ${\displaystyle T}$ classifiers ${\displaystyle h_{1},\ldots ,h_{T}\in B}$ and a weight vector ${\displaystyle w\in \mathbb {R} ^{T}}$, we can define the following classifier:

${\displaystyle f(x)=\operatorname {sign} \left(\sum _{t=1}^{T}w_{t}\cdot h_{t}(x)\right)}$

The VC dimension of the set of all such classifiers (for all selections of ${\displaystyle T}$ classifiers from ${\displaystyle B}$ and a weight-vector from ${\displaystyle \mathbb {R} ^{T}}$), assuming ${\displaystyle T,D\geq 3}$, is at most:[5]:108–109

${\displaystyle T\cdot (D+1)\cdot (3\log(T\cdot (D+1))+2)}$

## VC dimension of a neural network

A neural network is described by a directed acyclic graph G(V,E), where:

• V is the set of nodes. Each node is a simple computation cell.
• E is the set of edges, Each edge has a weight.
• The input to the network is represented by the sources of the graph – the nodes with no incoming edges.
• The output of the network is represented by the sinks of the graph – the nodes with no outgoing edges.
• Each intermediate node gets as input a weighted sum of the outputs of the nodes at its incoming edges, where the weights are the weights on the edges.
• Each intermediate node outputs a certain increasing function of its input, such as the sign function or the sigmoid function. This function is called the activation function.

The VC dimension of a neural network is bounded as follows:[5]:234–235

• If the activation function is the sign function and the weights are general, then the VC dimension is at most ${\displaystyle O(|E|\cdot \log(|E|))}$.
• If the activation function is the sigmoid function and the weights are general, then the VC dimension is at least ${\displaystyle \Omega (|E|^{2})}$ and at most ${\displaystyle O(|E|^{2}\cdot |V|^{2})}$.
• If the weights come from a finite family (e.g. the weights are real numbers that can be represented by at most 32 bits in a computer), then, for both activation functions, the VC dimension is at most ${\displaystyle O(|E|)}$.

## Generalizations

The VC dimension is defined for spaces of binary functions (functions to {0,1}). Several generalizations have been suggested for spaces of non-binary functions.

• For multi-valued functions (functions to {0,...,n}), the Natarajan dimension[6] can be used. Ben David et al[7] present a generalization of this concept.
• For real-valued functions (e.g. functions to a real interval, [0,1]), Pollard's pseudo-dimension[8][9][10] can be used.
• The Rademacher complexity provides similar bounds to the VC, and can sometimes provide more insight than VC dimension calculations into such statistical methods such as those using kernels[citation needed].

## Footnotes

1. ^ Vapnik, V. N.; Chervonenkis, A. Ya. (1971). "On the Uniform Convergence of Relative Frequencies of Events to Their Probabilities". Theory of Probability & Its Applications. 16 (2): 264. doi:10.1137/1116025. This is an English translation, by B. Seckler, of the Russian paper: "On the Uniform Convergence of Relative Frequencies of Events to Their Probabilities". Dokl. Akad. Nauk. 181 (4): 781. 1968. The translation was reproduced as: Vapnik, V. N.; Chervonenkis, A. Ya. (2015). "On the Uniform Convergence of Relative Frequencies of Events to Their Probabilities". Measures of Complexity. p. 11. doi:10.1007/978-3-319-21852-6_3. ISBN 978-3-319-21851-9.
2. ^ a b c d Mohri, Mehryar; Rostamizadeh, Afshin; Talwalkar, Ameet (2012). Foundations of Machine Learning. USA, Massachusetts: MIT Press. ISBN 9780262018258.
3. ^
4. ^ Alon, N.; Haussler, D.; Welzl, E. (1987). "Partitioning and geometric embedding of range spaces of finite Vapnik-Chervonenkis dimension". Proceedings of the third annual symposium on Computational geometry – SCG '87. p. 331. doi:10.1145/41958.41994. ISBN 978-0897912310. S2CID 7394360.
5. ^ a b Shalev-Shwartz, Shai; Ben-David, Shai (2014). Understanding Machine Learning – from Theory to Algorithms. Cambridge University Press. ISBN 9781107057135.
6. ^
7. ^
8. ^
9. ^
10. ^
11. ^