# Support Vector Machine Wikipedia

Set of methods for supervised statistical learning

In machine learning, support vector machines (SVMs, also support vector networks[1]) are supervised learning models with associated learning algorithms that analyze data for classification and regression analysis. Developed at AT&T Bell Laboratories by Vladimir Vapnik with colleagues (Boser et al., 1992, Guyon et al., 1993, Cortes and Vapnik, 1995,[1] Vapnik et al., 1997[citation needed]) SVMs are one of the most robust prediction methods, being based on statistical learning frameworks or VC theory proposed by Vapnik (1982, 1995) and Chervonenkis (1974). Given a set of training examples, each marked as belonging to one of two categories, an SVM training algorithm builds a model that assigns new examples to one category or the other, making it a non-probabilistic binary linear classifier (although methods such as Platt scaling exist to use SVM in a probabilistic classification setting). SVM maps training examples to points in space so as to maximise the width of the gap between the two categories. New examples are then mapped into that same space and predicted to belong to a category based on which side of the gap they fall.

In addition to performing linear classification, SVMs can efficiently perform a non-linear classification using what is called the kernel trick, implicitly mapping their inputs into high-dimensional feature spaces.

When data are unlabelled, supervised learning is not possible, and an unsupervised learning approach is required, which attempts to find natural clustering of the data to groups, and then map new data to these formed groups. The support vector clustering[2] algorithm, created by Hava Siegelmann and Vladimir Vapnik, applies the statistics of support vectors, developed in the support vector machines algorithm, to categorize unlabeled data.[citation needed]

Motivation[edit]

H1 does not separate the classes. H2 does, but only with a small margin. H3 separates them with the maximal margin.

Classifying data is a common task in machine learning. Suppose some given data points each belong to one of two classes, and the goal is to decide which class a new data point will be in. In the case of support vector machines, a data point is viewed as a p {\displaystyle p} -dimensional vector (a list of p {\displaystyle p} numbers), and we want to know whether we can separate such points with a ( p − 1 ) {\displaystyle (p-1)} -dimensional hyperplane. This is called a linear classifier. There are many hyperplanes that might classify the data. One reasonable choice as the best hyperplane is the one that represents the largest separation, or margin, between the two classes. So we choose the hyperplane so that the distance from it to the nearest data point on each side is maximized. If such a hyperplane exists, it is known as the maximum-margin hyperplane and the linear classifier it defines is known as a maximum-margin classifier; or equivalently, the perceptron of optimal stability.[citation needed]

More formally, a support vector machine constructs a hyperplane or set of hyperplanes in a high or infinite-dimensional space, which can be used for classification, regression, or other tasks like outliers detection.[3] Intuitively, a good separation is achieved by the hyperplane that has the largest distance to the nearest training-data point of any class (so-called functional margin), since in general the larger the margin, the lower the generalization error of the classifier.[4]

Whereas the original problem may be stated in a finite-dimensional space, it often happens that the sets to discriminate are not linearly separable in that space. For this reason, it was proposed[5] that the original finite-dimensional space be mapped into a much higher-dimensional space, presumably making the separation easier in that space. To keep the computational load reasonable, the mappings used by SVM schemes are designed to ensure that dot products of pairs of input data vectors may be computed easily in terms of the variables in the original space, by defining them in terms of a kernel function k ( x , y ) {\displaystyle k(x,y)} selected to suit the problem.[6] The hyperplanes in the higher-dimensional space are defined as the set of points whose dot product with a vector in that space is constant, where such a set of vectors is an orthogonal (and thus minimal) set of vectors that defines a hyperplane. The vectors defining the hyperplanes can be chosen to be linear combinations with parameters α i {\displaystyle \alpha _{i}} of images of feature vectors x i {\displaystyle x_{i}} that occur in the data base. With this choice of a hyperplane, the points x {\displaystyle x} in the feature space that are mapped into the hyperplane are defined by the relation ∑ i α i k ( x i , x ) = constant . {\displaystyle \textstyle \sum _{i}\alpha _{i}k(x_{i},x)={\text{constant}}.} Note that if k ( x , y ) {\displaystyle k(x,y)} becomes small as y {\displaystyle y} grows further away from x {\displaystyle x} , each term in the sum measures the degree of closeness of the test point x {\displaystyle x} to the corresponding data base point x i {\displaystyle x_{i}} . In this way, the sum of kernels above can be used to measure the relative nearness of each test point to the data points originating in one or the other of the sets to be discriminated. Note the fact that the set of points x {\displaystyle x} mapped into any hyperplane can be quite convoluted as a result, allowing much more complex discrimination between sets that are not convex at all in the original space.

SVMs can be used to solve various real-world problems:

* SVMs are helpful in text and hypertext categorization, as their application can significantly reduce the need for labeled training instances in both the standard inductive and transductive settings.[7] Some methods for shallow semantic parsing are based on support vector machines.[8]

* Classification of images can also be performed using SVMs. Experimental results show that SVMs achieve significantly higher search accuracy than traditional query refinement schemes after just three to four rounds of relevance feedback. This is also true for image segmentation systems, including those using a modified version SVM that uses the privileged approach as suggested by Vapnik.[9][10]

* Classification of satellite data like SAR data using supervised SVM.[11]

* Hand-written characters can be recognized using SVM.[12][13]

* The SVM algorithm has been widely applied in the biological and other sciences. They have been used to classify proteins with up to 90% of the compounds classified correctly. Permutation tests based on SVM weights have been suggested as a mechanism for interpretation of SVM models.[14][15] Support vector machine weights have also been used to interpret SVM models in the past.[16] Posthoc interpretation of support vector machine models in order to identify features used by the model to make predictions is a relatively new area of research with special significance in the biological sciences.

History[edit]

The original SVM algorithm was invented by Vladimir N. Vapnik and Alexey Ya. Chervonenkis in 1963.[citation needed] In 1992, Bernhard Boser, Isabelle Guyon and Vladimir Vapnik suggested a way to create nonlinear classifiers by applying the kernel trick to maximum-margin hyperplanes.[5] The “soft margin” incarnation, as is commonly used in software packages, was proposed by Corinna Cortes and Vapnik in 1993 and published in 1995.[1]

Linear SVM[edit]

Maximum-margin hyperplane and margins for an SVM trained with samples from two classes. Samples on the margin are called the support vectors.

We are given a training dataset of n {\displaystyle n} points of the form

( x 1 , y 1 ) , … , ( x n , y n ) , {\displaystyle (\mathbf {x} _{1},y_{1}),\ldots ,(\mathbf {x} _{n},y_{n}),}

where the y i {\displaystyle y_{i}} are either 1 or −1, each indicating the class to which the point x i {\displaystyle \mathbf {x} _{i}} belongs. Each x i {\displaystyle \mathbf {x} _{i}} is a p {\displaystyle p} -dimensional real vector. We want to find the “maximum-margin hyperplane” that divides the group of points x i {\displaystyle \mathbf {x} _{i}} for which y i = 1 {\displaystyle y_{i}=1} from the group of points for which y i = − 1 {\displaystyle y_{i}=-1} , which is defined so that the distance between the hyperplane and the nearest point x i {\displaystyle \mathbf {x} _{i}} from either group is maximized.

Any hyperplane can be written as the set of points x {\displaystyle \mathbf {x} } satisfying

w T x − b = 0 , {\displaystyle \mathbf {w} ^{\mathsf {T}}\mathbf {x} -b=0,}

where w {\displaystyle \mathbf {w} } is the (not necessarily normalized) normal vector to the hyperplane. This is much like Hesse normal form, except that w {\displaystyle \mathbf {w} } is not necessarily a unit vector. The parameter b ‖ w ‖ \displaystyle \tfrac {b} determines the offset of the hyperplane from the origin along the normal vector w {\displaystyle \mathbf {w} } .

Hard-margin[edit]

If the training data is linearly separable, we can select two parallel hyperplanes that separate the two classes of data, so that the distance between them is as large as possible. The region bounded by these two hyperplanes is called the “margin”, and the maximum-margin hyperplane is the hyperplane that lies halfway between them. With a normalized or standardized dataset, these hyperplanes can be described by the equations

w T x − b = 1 {\displaystyle \mathbf {w} ^{\mathsf {T}}\mathbf {x} -b=1} (anything on or above this boundary is of one class, with label 1)and

w T x − b = − 1 {\displaystyle \mathbf {w} ^{\mathsf {T}}\mathbf {x} -b=-1} (anything on or below this boundary is of the other class, with label −1).Geometrically, the distance between these two hyperplanes is 2 ‖ w ‖ \displaystyle \tfrac {2}\ ,[17] so to maximize the distance between the planes we want to minimize ‖ w ‖ . The distance is computed using the distance from a point to a plane equation. We also have to prevent data points from falling into the margin, we add the following constraint: for each i {\displaystyle i} either

w T x i − b ≥ 1 , if y i = 1 , {\displaystyle \mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b\geq 1\,,{\text{ if }}y_{i}=1,}

or w T x i − b ≤ − 1 , if y i = − 1. {\displaystyle \mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b\leq -1\,,{\text{ if }}y_{i}=-1.}

These constraints state that each data point must lie on the correct side of the margin.

This can be rewritten as

y i ( w T x i − b ) ≥ 1 , for all 1 ≤ i ≤ n . {\displaystyle y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b)\geq 1,\quad {\text{ for all }}1\leq i\leq n.}

(1)

We can put this together to get the optimization problem:

minimize w , b ‖ w ‖ 2 2 subject to y i ( w ⊤ x i − b ) ≥ 1 ∀ i ∈ { 1 , … , n } \displaystyle \begin{aligned}&{\underset {\mathbf {w} ,\;b}{\operatorname {minimize} }}&&\

The w {\displaystyle \mathbf {w} } and b {\displaystyle b} that solve this problem determine our classifier, x ↦ sgn ( w T x − b ) {\displaystyle \mathbf {x} \mapsto \operatorname {sgn}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} -b)} where sgn ( ⋅ ) {\displaystyle \operatorname {sgn}(\cdot )} is the sign function.

An important consequence of this geometric description is that the max-margin hyperplane is completely determined by those x i {\displaystyle \mathbf {x} _{i}} that lie nearest to it. These x i {\displaystyle \mathbf {x} _{i}} are called support vectors.

Soft-margin[edit]

To extend SVM to cases in which the data are not linearly separable, the hinge loss function is helpful

max ( 0 , 1 − y i ( w T x i − b ) ) . {\displaystyle \max \left(0,1-y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b)\right).}

Note that y i {\displaystyle y_{i}} is the i-th target (i.e., in this case, 1 or −1), and w T x i − b {\displaystyle \mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b} is the i-th output.

This function is zero if the constraint in (1) is satisfied, in other words, if x i {\displaystyle \mathbf {x} _{i}} lies on the correct side of the margin. For data on the wrong side of the margin, the function’s value is proportional to the distance from the margin.

The goal of the optimization then is to minimize

λ ‖ w ‖ 2 + [ 1 n ∑ i = 1 n max ( 0 , 1 − y i ( w T x i − b ) ) ] , {\displaystyle \lambda \lVert \mathbf {w} \rVert ^{2}+\left[{\frac {1}{n}}\sum _{i=1}^{n}\max \left(0,1-y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b)\right)\right],}

where the parameter λ > 0 {\displaystyle \lambda >0} determines the trade-off between increasing the margin size and ensuring that the x i {\displaystyle \mathbf {x} _{i}} lie on the correct side of the margin. By deconstructing the hinge loss, this optimization problem can be massaged into the following:

minimize w , b , ζ ‖ w ‖ 2 2 + C ∑ i = 1 N ζ i subject to y i ( w ⊤ x i − b ) ≥ 1 − ζ i , ζ i ≥ 0 ∀ i ∈ { 1 , … , n } \displaystyle _{2}^{2}+C\sum _{i=1}^{N}\zeta _{i}\\&{\text{subject to}}&&y_{i}(\mathbf {w} ^{\top }\mathbf {x} _{i}-b)\geq 1-\zeta _{i},\quad \zeta _{i}\geq 0\quad \forall i\in \{1,\dots ,n\}\end{aligned}

Thus, for large values of C {\displaystyle C} , it will behave similar to the hard-margin SVM, if the input data are linearly classifiable, but will still learn if a classification rule is viable or not. ( λ {\displaystyle \lambda } is inversely related to C {\displaystyle C} , e.g. in LIBSVM.)

Nonlinear Kernels[edit]

The original maximum-margin hyperplane algorithm proposed by Vapnik in 1963 constructed a linear classifier. However, in 1992, Bernhard Boser, Isabelle Guyon and Vladimir Vapnik suggested a way to create nonlinear classifiers by applying the kernel trick (originally proposed by Aizerman et al.[18]) to maximum-margin hyperplanes.[5] The resulting algorithm is formally similar, except that every dot product is replaced by a nonlinear kernel function. This allows the algorithm to fit the maximum-margin hyperplane in a transformed feature space. The transformation may be nonlinear and the transformed space high-dimensional; although the classifier is a hyperplane in the transformed feature space, it may be nonlinear in the original input space.

It is noteworthy that working in a higher-dimensional feature space increases the generalization error of support vector machines, although given enough samples the algorithm still performs well.[19]

Some common kernels include:

* Polynomial (homogeneous): k ( x i , x j ) = ( x i ⋅ x j ) d {\displaystyle k(\mathbf {x} _{i},\mathbf {x} _{j})=(\mathbf {x} _{i}\cdot \mathbf {x} _{j})^{d}} . Particularly, when d = 1 {\displaystyle d=1} , this becomes the linear kernel.

* Polynomial (inhomogeneous): k ( x i , x j ) = ( x i ⋅ x j + r ) d {\displaystyle k(\mathbf {x} _{i},\mathbf {x} _{j})=(\mathbf {x} _{i}\cdot \mathbf {x} _{j}+r)^{d}} .

* Gaussian radial basis function: k ( x i , x j ) = exp ( − γ ‖ x i − x j ‖ 2 ) ^{2}\right) for γ > 0 {\displaystyle \gamma >0} . Sometimes parametrized using γ = 1 / ( 2 σ 2 ) {\displaystyle \gamma =1/(2\sigma ^{2})} .

* Sigmoid function (Hyperbolic tangent): k ( x i , x j ) = tanh ( κ x i ⋅ x j + c ) {\displaystyle k(\mathbf {x_{i}} ,\mathbf {x_{j}} )=\tanh(\kappa \mathbf {x} _{i}\cdot \mathbf {x} _{j}+c)} for some (not every) κ > 0 {\displaystyle \kappa >0} and c <<> 0 \displaystyle c .

The kernel is related to the transform φ ( x i ) {\displaystyle \varphi (\mathbf {x} _{i})} by the equation k ( x i , x j ) = φ ( x i ) ⋅ φ ( x j ) {\displaystyle k(\mathbf {x} _{i},\mathbf {x} _{j})=\varphi (\mathbf {x} _{i})\cdot \varphi (\mathbf {x_{j}} )} . The value w is also in the transformed space, with w = ∑ i α i y i φ ( x i ) {\textstyle \mathbf {w} =\sum _{i}\alpha _{i}y_{i}\varphi (\mathbf {x} _{i})} . Dot products with w for classification can again be computed by the kernel trick, i.e. w ⋅ φ ( x ) = ∑ i α i y i k ( x i , x ) {\textstyle \mathbf {w} \cdot \varphi (\mathbf {x} )=\sum _{i}\alpha _{i}y_{i}k(\mathbf {x} _{i},\mathbf {x} )} .

Computing the SVM classifier[edit]

Computing the (soft-margin) SVM classifier amounts to minimizing an expression of the form

[ 1 n ∑ i = 1 n max ( 0 , 1 − y i ( w T x i − b ) ) ] + λ ‖ w ‖ 2 . \displaystyle \left[{\frac {1}{n}}\sum _{i=1}^{n}\max \left(0,1-y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b)\right)\right]+\lambda \

(2)

We focus on the soft-margin classifier since, as noted above, choosing a sufficiently small value for λ {\displaystyle \lambda } yields the hard-margin classifier for linearly classifiable input data. The classical approach, which involves reducing (2) to a quadratic programming problem, is detailed below. Then, more recent approaches such as sub-gradient descent and coordinate descent will be discussed.

Minimizing (2) can be rewritten as a constrained optimization problem with a differentiable objective function in the following way.

For each i ∈ { 1 , … , n } {\displaystyle i\in \{1,\,\ldots ,\,n\}} we introduce a variable ζ i = max ( 0 , 1 − y i ( w T x i − b ) ) {\displaystyle \zeta _{i}=\max \left(0,1-y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b)\right)} . Note that ζ i {\displaystyle \zeta _{i}} is the smallest nonnegative number satisfying y i ( w T x i − b ) ≥ 1 − ζ i . {\displaystyle y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b)\geq 1-\zeta _{i}.}

Thus we can rewrite the optimization problem as follows

minimize 1 n ∑ i = 1 n ζ i + λ ‖ w ‖ 2 subject to y i ( w T x i − b ) ≥ 1 − ζ i and ζ i ≥ 0 , for all i . \displaystyle \mathbf {w} \

This is called the primal problem.

By solving for the Lagrangian dual of the above problem, one obtains the simplified problem

maximize f ( c 1 … c n ) = ∑ i = 1 n c i − 1 2 ∑ i = 1 n ∑ j = 1 n y i c i ( x i T x j ) y j c j , subject to ∑ i = 1 n c i y i = 0 , and 0 ≤ c i ≤ 1 2 n λ for all i . {\displaystyle {\begin{aligned}&{\text{maximize}}\,\,f(c_{1}\ldots c_{n})=\sum _{i=1}^{n}c_{i}-{\frac {1}{2}}\sum _{i=1}^{n}\sum _{j=1}^{n}y_{i}c_{i}(\mathbf {x} _{i}^{\mathsf {T}}\mathbf {x} _{j})y_{j}c_{j},\\&{\text{subject to }}\sum _{i=1}^{n}c_{i}y_{i}=0,\,{\text{and }}0\leq c_{i}\leq {\frac {1}{2n\lambda }}\;{\text{for all }}i.\end{aligned}}}

This is called the dual problem. Since the dual maximization problem is a quadratic function of the c i {\displaystyle c_{i}} subject to linear constraints, it is efficiently solvable by quadratic programming algorithms.

Here, the variables c i {\displaystyle c_{i}} are defined such that

w = ∑ i = 1 n c i y i x i . {\displaystyle \mathbf {w} =\sum _{i=1}^{n}c_{i}y_{i}\mathbf {x} _{i}.}

Moreover, c i = 0 {\displaystyle c_{i}=0} exactly when x i {\displaystyle \mathbf {x} _{i}} lies on the correct side of the margin, and 0 <<> c i <<> ( 2 n λ ) − 1 \displaystyle 0 when x i {\displaystyle \mathbf {x} _{i}} lies on the margin’s boundary. It follows that w {\displaystyle \mathbf {w} } can be written as a linear combination of the support vectors.

The offset, b {\displaystyle b} , can be recovered by finding an x i {\displaystyle \mathbf {x} _{i}} on the margin’s boundary and solving

y i ( w T x i − b ) = 1 ⟺ b = w T x i − y i . {\displaystyle y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-b)=1\iff b=\mathbf {w} ^{\mathsf {T}}\mathbf {x} _{i}-y_{i}.}

(Note that y i − 1 = y i {\displaystyle y_{i}^{-1}=y_{i}} since y i = ± 1 {\displaystyle y_{i}=\pm 1} .)

Kernel trick[edit]

A training example of SVM with kernel given by φ((a, b)) = (a, b, a2 + b2)

Suppose now that we would like to learn a nonlinear classification rule which corresponds to a linear classification rule for the transformed data points φ ( x i ) . {\displaystyle \varphi (\mathbf {x} _{i}).} Moreover, we are given a kernel function k {\displaystyle k} which satisfies k ( x i , x j ) = φ ( x i ) ⋅ φ ( x j ) {\displaystyle k(\mathbf {x} _{i},\mathbf {x} _{j})=\varphi (\mathbf {x} _{i})\cdot \varphi (\mathbf {x} _{j})} .

We know the classification vector w {\displaystyle \mathbf {w} } in the transformed space satisfies

w = ∑ i = 1 n c i y i φ ( x i ) , {\displaystyle \mathbf {w} =\sum _{i=1}^{n}c_{i}y_{i}\varphi (\mathbf {x} _{i}),}

where, the c i {\displaystyle c_{i}} are obtained by solving the optimization problem

maximize f ( c 1 … c n ) = ∑ i = 1 n c i − 1 2 ∑ i = 1 n ∑ j = 1 n y i c i ( φ ( x i ) ⋅ φ ( x j ) ) y j c j = ∑ i = 1 n c i − 1 2 ∑ i = 1 n ∑ j = 1 n y i c i k ( x i , x j ) y j c j subject to ∑ i = 1 n c i y i = 0 , and 0 ≤ c i ≤ 1 2 n λ for all i . {\displaystyle {\begin{aligned}{\text{maximize}}\,\,f(c_{1}\ldots c_{n})&=\sum _{i=1}^{n}c_{i}-{\frac {1}{2}}\sum _{i=1}^{n}\sum _{j=1}^{n}y_{i}c_{i}(\varphi (\mathbf {x} _{i})\cdot \varphi (\mathbf {x} _{j}))y_{j}c_{j}\\&=\sum _{i=1}^{n}c_{i}-{\frac {1}{2}}\sum _{i=1}^{n}\sum _{j=1}^{n}y_{i}c_{i}k(\mathbf {x} _{i},\mathbf {x} _{j})y_{j}c_{j}\\{\text{subject to }}\sum _{i=1}^{n}c_{i}y_{i}&=0,\,{\text{and }}0\leq c_{i}\leq {\frac {1}{2n\lambda }}\;{\text{for all }}i.\end{aligned}}}

The coefficients c i {\displaystyle c_{i}} can be solved for using quadratic programming, as before. Again, we can find some index i {\displaystyle i} such that 0 <<> c i <<> ( 2 n λ ) − 1 \displaystyle 0 , so that φ ( x i ) {\displaystyle \varphi (\mathbf {x} _{i})} lies on the boundary of the margin in the transformed space, and then solve

b = w T φ ( x i ) − y i = [ ∑ j = 1 n c j y j φ ( x j ) ⋅ φ ( x i ) ] − y i = [ ∑ j = 1 n c j y j k ( x j , x i ) ] − y i . {\displaystyle {\begin{aligned}b=\mathbf {w} ^{\mathsf {T}}\varphi (\mathbf {x} _{i})-y_{i}&=\left[\sum _{j=1}^{n}c_{j}y_{j}\varphi (\mathbf {x} _{j})\cdot \varphi (\mathbf {x} _{i})\right]-y_{i}\\&=\left[\sum _{j=1}^{n}c_{j}y_{j}k(\mathbf {x} _{j},\mathbf {x} _{i})\right]-y_{i}.\end{aligned}}}

Finally,

z ↦ sgn ( w T φ ( z ) − b ) = sgn ( [ ∑ i = 1 n c i y i k ( x i , z ) ] − b ) . {\displaystyle \mathbf {z} \mapsto \operatorname {sgn}(\mathbf {w} ^{\mathsf {T}}\varphi (\mathbf {z} )-b)=\operatorname {sgn} \left(\left[\sum _{i=1}^{n}c_{i}y_{i}k(\mathbf {x} _{i},\mathbf {z} )\right]-b\right).}

Modern methods[edit]

Recent algorithms for finding the SVM classifier include sub-gradient descent and coordinate descent. Both techniques have proven to offer significant advantages over the traditional approach when dealing with large, sparse datasets—sub-gradient methods are especially efficient when there are many training examples, and coordinate descent when the dimension of the feature space is high.

Sub-gradient descent[edit]

Sub-gradient descent algorithms for the SVM work directly with the expression

f ( w , b ) = [ 1 n ∑ i = 1 n max ( 0 , 1 − y i ( w T x i − b ) ) ] + λ ‖ w ‖ 2 . \mathbf {w} \

Note that f {\displaystyle f} is a convex function of w {\displaystyle \mathbf {w} } and b {\displaystyle b} . As such, traditional gradient descent (or SGD) methods can be adapted, where instead of taking a step in the direction of the function’s gradient, a step is taken in the direction of a vector selected from the function’s sub-gradient. This approach has the advantage that, for certain implementations, the number of iterations does not scale with n {\displaystyle n} , the number of data points.[20]

Coordinate descent[edit]

Coordinate descent algorithms for the SVM work from the dual problem

maximize f ( c 1 … c n ) = ∑ i = 1 n c i − 1 2 ∑ i = 1 n ∑ j = 1 n y i c i ( x i ⋅ x j ) y j c j , subject to ∑ i = 1 n c i y i = 0 , and 0 ≤ c i ≤ 1 2 n λ for all i . {\displaystyle {\begin{aligned}&{\text{maximize}}\,\,f(c_{1}\ldots c_{n})=\sum _{i=1}^{n}c_{i}-{\frac {1}{2}}\sum _{i=1}^{n}\sum _{j=1}^{n}y_{i}c_{i}(x_{i}\cdot x_{j})y_{j}c_{j},\\&{\text{subject to }}\sum _{i=1}^{n}c_{i}y_{i}=0,\,{\text{and }}0\leq c_{i}\leq {\frac {1}{2n\lambda }}\;{\text{for all }}i.\end{aligned}}}

For each i ∈ { 1 , … , n } {\displaystyle i\in \{1,\,\ldots ,\,n\}} , iteratively, the coefficient c i {\displaystyle c_{i}} is adjusted in the direction of ∂ f / ∂ c i {\displaystyle \partial f/\partial c_{i}} . Then, the resulting vector of coefficients ( c 1 ′ , … , c n ′ ) {\displaystyle (c_{1}’,\,\ldots ,\,c_{n}’)} is projected onto the nearest vector of coefficients that satisfies the given constraints. (Typically Euclidean distances are used.) The process is then repeated until a near-optimal vector of coefficients is obtained. The resulting algorithm is extremely fast in practice, although few performance guarantees have been proven.[21]

Empirical risk minimization[edit]

The soft-margin support vector machine described above is an example of an empirical risk minimization (ERM) algorithm for the hinge loss. Seen this way, support vector machines belong to a natural class of algorithms for statistical inference, and many of its unique features are due to the behavior of the hinge loss. This perspective can provide further insight into how and why SVMs work, and allow us to better analyze their statistical properties.

Risk minimization[edit]

In supervised learning, one is given a set of training examples X 1 … X n {\displaystyle X_{1}\ldots X_{n}} with labels y 1 … y n {\displaystyle y_{1}\ldots y_{n}} , and wishes to predict y n + 1 {\displaystyle y_{n+1}} given X n + 1 {\displaystyle X_{n+1}} . To do so one forms a hypothesis, f {\displaystyle f} , such that f ( X n + 1 ) {\displaystyle f(X_{n+1})} is a “good” approximation of y n + 1 {\displaystyle y_{n+1}} . A “good” approximation is usually defined with the help of a loss function, ℓ ( y , z ) {\displaystyle \ell (y,z)} , which characterizes how bad z {\displaystyle z} is as a prediction of y {\displaystyle y} . We would then like to choose a hypothesis that minimizes the expected risk:

ε ( f ) = E [ ℓ ( y n + 1 , f ( X n + 1 ) ) ] . {\displaystyle \varepsilon (f)=\mathbb {E} \left[\ell (y_{n+1},f(X_{n+1}))\right].}

In most cases, we don’t know the joint distribution of X n + 1 , y n + 1 {\displaystyle X_{n+1},\,y_{n+1}} outright. In these cases, a common strategy is to choose the hypothesis that minimizes the empirical risk:

ε ^ ( f ) = 1 n ∑ k = 1 n ℓ ( y k , f ( X k ) ) . {\displaystyle {\hat {\varepsilon }}(f)={\frac {1}{n}}\sum _{k=1}^{n}\ell (y_{k},f(X_{k})).}

Under certain assumptions about the sequence of random variables X k , y k {\displaystyle X_{k},\,y_{k}} (for example, that they are generated by a finite Markov process), if the set of hypotheses being considered is small enough, the minimizer of the empirical risk will closely approximate the minimizer of the expected risk as n {\displaystyle n} grows large. This approach is called empirical risk minimization, or ERM.

Regularization and stability[edit]

In order for the minimization problem to have a well-defined solution, we have to place constraints on the set H {\displaystyle {\mathcal {H}}} of hypotheses being considered. If H {\displaystyle {\mathcal {H}}} is a normed space (as is the case for SVM), a particularly effective technique is to consider only those hypotheses f {\displaystyle f} for which ‖ f ‖ H <<> k \displaystyle \lVert f\rVert _{\mathcal {H}} . This is equivalent to imposing a regularization penalty R ( f ) = λ k ‖ f ‖ H {\displaystyle {\mathcal {R}}(f)=\lambda _{k}\lVert f\rVert _{\mathcal {H}}} , and solving the new optimization problem

f ^ = a r g min f ∈ H ε ^ ( f ) + R ( f ) . {\displaystyle {\hat {f}}=\mathrm {arg} \min _{f\in {\mathcal {H}}}{\hat {\varepsilon }}(f)+{\mathcal {R}}(f).}

This approach is called Tikhonov regularization.

More generally, R ( f ) {\displaystyle {\mathcal {R}}(f)} can be some measure of the complexity of the hypothesis f {\displaystyle f} , so that simpler hypotheses are preferred.

SVM and the hinge loss[edit]

Recall that the (soft-margin) SVM classifier w ^ , b : x ↦ sgn ( w ^ T x − b ) {\displaystyle {\hat {\mathbf {w} }},b:\mathbf {x} \mapsto \operatorname {sgn}({\hat {\mathbf {w} }}^{\mathsf {T}}\mathbf {x} -b)} is chosen to minimize the following expression:

[ 1 n ∑ i = 1 n max ( 0 , 1 − y i ( w T x − b ) ) ] + λ ‖ w ‖ 2 . \displaystyle \left[{\frac {1}{n}}\sum _{i=1}^{n}\max \left(0,1-y_{i}(\mathbf {w} ^{\mathsf {T}}\mathbf {x} -b)\right)\right]+\lambda \

In light of the above discussion, we see that the SVM technique is equivalent to empirical risk minimization with Tikhonov regularization, where in this case the loss function is the hinge loss

ℓ ( y , z ) = max ( 0 , 1 − y z ) . {\displaystyle \ell (y,z)=\max \left(0,1-yz\right).}

From this perspective, SVM is closely related to other fundamental classification algorithms such as regularized least-squares and logistic regression. The difference between the three lies in the choice of loss function: regularized least-squares amounts to empirical risk minimization with the square-loss, ℓ s q ( y , z ) = ( y − z ) 2 {\displaystyle \ell _{sq}(y,z)=(y-z)^{2}} ; logistic regression employs the log-loss,

ℓ log ( y , z ) = ln ( 1 + e − y z ) . {\displaystyle \ell _{\log }(y,z)=\ln(1+e^{-yz}).}

Target functions[edit]

The difference between the hinge loss and these other loss functions is best stated in terms of target functions – the function that minimizes expected risk for a given pair of random variables X , y {\displaystyle X,\,y} .

In particular, let y x {\displaystyle y_{x}} denote y {\displaystyle y} conditional on the event that X = x {\displaystyle X=x} . In the classification setting, we have:

y x = 1 with probability p x − 1 with probability 1 − p x {\displaystyle y_{x}={\begin{cases}1&{\text{with probability }}p_{x}\\-1&{\text{with probability }}1-p_{x}\end{cases}}}

The optimal classifier is therefore:

f ∗ ( x ) = y i − ⟨ w , x i ⟩ − b