User:Suhas Vijaykumar/svm

From Wikipedia, the free encyclopedia

 Linear SVM[edit]

We're given a training dataset of points, which are of the form

where the are either 1 or −1, each indicating the class to which the point belongs. Each is a -dimensional real vector. We want to find the "maximum-margin hyperplane" that divides the points for which , and those for which , which is defined so that the distance between the hyperplane and the nearest point is maximized.

Any hyperplane can be written as the set of points satisfying

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

where is the (not necessarily normalized) normal vector to the hyperplane. The parameter determines the offset of the hyperplane from the origin along the normal vector .

Hard-margin[edit]

If the training data are linearly separable, we select two hyperplanes that separate the two classes of data, so that the distance between them is as large as possible. The region bounded by the two hyperplanes is called "the margin". These hyperplanes can be described by the equations

and

Geometrically, the distance between these two hyperplanes is , so to maximize the distance between the planes we want to minimize . As we also have to prevent data points from falling into the margin, we add the following constraint: for each either

if

or

if

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

This can be rewritten as:

We can put this together to get the optimization problem:

"Minimize subject to for "

The and that solve this problem determine our classifier, .

An easy-to-see but important consequence of this geometric description is that max-margin hyperplane is completely determined by those which lie nearest to it. These are called support vectors.

Soft-margin[edit]

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

This function is zero if the constraint in (1) is satisfied, in other words, if 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. We then wish to minimize

where the parameter determines the tradeoff between increasing the margin-size and ensuring that the lie on the correct side of the margin. Thus, for sufficiently small values of , the soft-margin SVM will behave identically to the hard-margin SVM if the input data are linearly classifiable, but will still learn a viable classification rule if not.

 Nonlinear Classification[edit]

Kernel machine

The original maximum-margin hyperplane algorithm proposed by Vapnik in 1963 constructed a linear classifier. However, in 1992, Bernhard E. Boser, Isabelle M. Guyon and Vladimir N. Vapnik suggested a way to create nonlinear classifiers by applying the kernel trick (originally proposed by Aizerman et al.[1]) to maximum-margin hyperplanes.[2] 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.[3]

Some common kernels include:

  • Polynomial (homogeneous):
  • Polynomial (inhomogeneous):
  • Gaussian radial basis function: , for . Sometimes parametrized using
  • Hyperbolic tangent: , for some (not every) and

The kernel is related to the transform by the equation . The value w is also in the transformed space, with . Dot products with w for classification can again be computed by the kernel trick, i.e. .

Computing the SVM Classifier[edit]

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

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

Primal[edit]

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

For each we introduce the variable , and note that if and only if is the smallest nonnegative number satisfying

Thus we can rewrite the optimization problem as follows

This is called the primal problem.

Dual[edit]

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

This is called the dual problem. Since the dual minimization problem is a quadratic function of the subject to linear constraints, it is efficiently solvable by quadratic programming algorithms. Here, the variables are defined such that

.

Moreover, exactly when lies on the correct side of the margin, and when lies on the margin's boundary. It follows that can be written as a linear combination of the support vectors. The offset, , can be recovered by finding an on the margin's boundary and solving

Kernel Trick[edit]

Suppose now that we would like to learn a nonlinear classification rule which corresponds to a linear classification rule for the transformed data points Moreover, we are given a kernel function which satisfies .

We know the classification vector in the transformed space satisfies

where the are obtained by solving the optimization problem

The coefficients can be solved for using quadratic programming, as before. Again, we can find some index such that , so that lies on the boundary of the margin in the transformed space, and then solve

Finally, new points can be classified by computing

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 work directly with the expression

Note that is a convex function of and . 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 , the number of data points.[4]

Coordinate descent[edit]

Coordinate descent algorithms for the SVM work from the dual problem

For each , iteratively, the coefficient is adjusted in the direction of . Then, the resulting vector of coefficients 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 proved.[5]

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 with labels , and wishes to predict given . To do so one forms a hypothesis, , such that is a "good" approximation of . A "good" approximation is usually defined with the help of a loss function, , which characterizes how bad is as a prediction of . We would then like to choose a hypothesis that minimizes the expected risk:

In most cases, we don't know the joint distribution of outright. In these cases, a common strategy is to choose the hypothesis that minimizes the empirical risk:

Under certain assumptions about the sequence of random variables (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 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 of hypotheses being considered. If is a normed space (as is the case for SVM), a particularly effective technique is to consider only those hypotheses for which . This is equivalent to imposing a regularization penalty , and solving the new optimization problem

.

This approach is called Tikhonov regularization.

More generally, can be some measure of the complexity of the hypothesis , so that simpler hypotheses are preferred.

SVM and the Hinge Loss[edit]

Recall that the (soft-margin) SVM classifier is chosen to minimize the following expression.

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

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, ; logistic regression employs the log-loss, .

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 .

In particular, let denote conditional on the event that . In the classification setting, we have:

The optimal classifier is therefore:

For the square-loss, the target function is the conditional expectation function, ; For the logistic loss, it's the logit function, . While both of these target functions yield the correct classifier, as , they give us more information than we need. In fact, they give us enough information to completely describe the distribution of .

On the other hand, one can check that the target function for the hinge loss is exactly . Thus, in a sufficiently rich hypothesis space—or equivalently, for an appropriately chosen kernel—the SVM classifier will converge to the simplest function (in terms of ) that correctly classifies the data. This extends the geometric interpretation of SVM—for linear classification, the empirical risk is minimized by any function whose margins lie between the support vectors, and the simplest of these is the max-margin classifier.[6]

  1. ^ Aizerman, Mark A.; Braverman, Emmanuel M.; and Rozonoer, Lev I. (1964). "Theoretical foundations of the potential function method in pattern recognition learning". Automation and Remote Control. 25: 821–837.{{cite journal}}: CS1 maint: multiple names: authors list (link)
  2. ^ Boser, B. E.; Guyon, I. M.; Vapnik, V. N. (1992). "A training algorithm for optimal margin classifiers". Proceedings of the fifth annual workshop on Computational learning theory - COLT '92. p. 144. doi:10.1145/130385.130401. ISBN 089791497X.
  3. ^ Jin, Chi; Wang, Liwei (2012). Dimensionality dependent PAC-Bayes margin bound. Advances in Neural Information Processing Systems.
  4. ^ Shalev-Shwartz, Shai; Singer, Yoram; Srebro, Nathan; Cotter, Andrew (2010-10-16). "Pegasos: primal estimated sub-gradient solver for SVM". Mathematical Programming. 127 (1): 3–30. doi:10.1007/s10107-010-0420-4. ISSN 0025-5610.
  5. ^ Hsieh, Cho-Jui; Chang, Kai-Wei; Lin, Chih-Jen; Keerthi, S. Sathiya; Sundararajan, S. (2008-01-01). "A Dual Coordinate Descent Method for Large-scale Linear SVM". Proceedings of the 25th International Conference on Machine Learning. ICML '08. New York, NY, USA: ACM: 408–415. doi:10.1145/1390156.1390208. ISBN 978-1-60558-205-4.
  6. ^ Rosasco, L; Vito, E; Caponnetto, A; Piana, M; Verri, A (2004-05-01). "Are Loss Functions All the Same?". Neural Computation. 16 (5): 1063–1076. doi:10.1162/089976604773135104. ISSN 0899-7667.