LIBSVM: a Library for Support Vector Machines

Similar documents
LIBSVM: a Library for Support Vector Machines (Version 2.32)

Introduction to Support Vector Machines

A Revisit to Support Vector Data Description (SVDD)

Working Set Selection Using Second Order Information for Training SVM

Outline. Basic concepts: SVM and kernels SVM primal/dual problems. Chih-Jen Lin (National Taiwan Univ.) 1 / 22

Training Support Vector Machines: Status and Challenges

A GENERAL FORMULATION FOR SUPPORT VECTOR MACHINES. Wei Chu, S. Sathiya Keerthi, Chong Jin Ong

Machine Learning. Support Vector Machines. Manfred Huber

A Simple Decomposition Method for Support Vector Machines

Support Vector Machines

Support Vector Machine (SVM) & Kernel CE-717: Machine Learning Sharif University of Technology. M. Soleymani Fall 2012

Support Vector Machine Regression for Volatile Stock Market Prediction

ν =.1 a max. of 10% of training set can be margin errors ν =.8 a max. of 80% of training can be margin errors

A Study on Sigmoid Kernels for SVM and the Training of non-psd Kernels by SMO-type Methods

Machine Learning. Lecture 6: Support Vector Machine. Feng Li.

SUPPORT VECTOR MACHINE FOR THE SIMULTANEOUS APPROXIMATION OF A FUNCTION AND ITS DERIVATIVE

Sequential Minimal Optimization (SMO)

SMO Algorithms for Support Vector Machines without Bias Term

Solving the SVM Optimization Problem

Formulation with slack variables

An introduction to Support Vector Machines

Support Vector Machine (SVM) and Kernel Methods

An Improved Conjugate Gradient Scheme to the Solution of Least Squares SVM

A NEW MULTI-CLASS SUPPORT VECTOR ALGORITHM

Nearest Neighbors Methods for Support Vector Machines

Statistical Machine Learning from Data

A Tutorial on Support Vector Machine

Support Vector Machine for Classification and Regression

Perceptron Revisited: Linear Separators. Support Vector Machines

Support Vector Machines: Maximum Margin Classifiers

Introduction to Support Vector Machines

ICS-E4030 Kernel Methods in Machine Learning

Improvements to Platt s SMO Algorithm for SVM Classifier Design

Support Vector Machine (SVM) and Kernel Methods

Support Vector Machines Explained

Jeff Howbert Introduction to Machine Learning Winter

Convex Optimization. Dani Yogatama. School of Computer Science, Carnegie Mellon University, Pittsburgh, PA, USA. February 12, 2014

Non-linear Support Vector Machines

Lecture Notes on Support Vector Machine

A Dual Coordinate Descent Method for Large-scale Linear SVM

Gaps in Support Vector Optimization

Lecture 9: Large Margin Classifiers. Linear Support Vector Machines

LINEAR CLASSIFIERS. J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

Support Vector Machines

Support Vector Machines and Kernel Methods

Support Vector Machines for Classification and Regression. 1 Linearly Separable Data: Hard Margin SVMs

Support Vector Machine (SVM) and Kernel Methods

Support Vector Machines

Lecture Support Vector Machine (SVM) Classifiers

Machine Learning Support Vector Machines. Prof. Matteo Matteucci

Learning with kernels and SVM

Support Vector Machines for Classification and Regression

Linear & nonlinear classifiers

MinOver Revisited for Incremental Support-Vector-Classification

Probability Estimates for Multi-class Classification by Pairwise Coupling

Support Vector Machines

Support Vector Machine (continued)

Support Vector Machines

EE613 Machine Learning for Engineers. Kernel methods Support Vector Machines. jean-marc odobez 2015

Support Vector Machines for Classification: A Statistical Portrait

NON-FIXED AND ASYMMETRICAL MARGIN APPROACH TO STOCK MARKET PREDICTION USING SUPPORT VECTOR REGRESSION. Haiqin Yang, Irwin King and Laiwan Chan

Support Vector Machines.

Convergence of a Generalized Gradient Selection Approach for the Decomposition Method

Constrained Optimization and Support Vector Machines

Support Vector Machines and Kernel Methods

Analysis of Multiclass Support Vector Machines

CS-E4830 Kernel Methods in Machine Learning

Probability Estimates for Multi-class Classification by Pairwise Coupling

Linear vs Non-linear classifier. CS789: Machine Learning and Neural Network. Introduction

Soft-margin SVM can address linearly separable problems with outliers

Support Vector Machines and Kernel Algorithms

Comments on the Core Vector Machines: Fast SVM Training on Very Large Data Sets

Outliers Treatment in Support Vector Regression for Financial Time Series Prediction

Iteratively Reweighted Least Square for Asymmetric L 2 -Loss Support Vector Regression

Classification and Support Vector Machine

Support Vector Machines

Square Penalty Support Vector Regression

SVM Incremental Learning, Adaptation and Optimization

Pattern Classification, and Quadratic Problems

SVM TRADE-OFF BETWEEN MAXIMIZE THE MARGIN AND MINIMIZE THE VARIABLES USED FOR REGRESSION

Discussion of Some Problems About Nonlinear Time Series Prediction Using ν-support Vector Machine

Support Vector Machines

Linear & nonlinear classifiers

Model Selection for LS-SVM : Application to Handwriting Recognition

Support Vector Machines

Support Vector Machine via Nonlinear Rescaling Method

Polyhedral Computation. Linear Classifiers & the SVM

SUPPORT VECTOR MACHINE

UVA CS 4501: Machine Learning

Linear Models. min. i=1... m. i=1...m

Support Vector Machines

Linear classifiers selecting hyperplane maximizing separation margin between classes (large margin classifiers)

Rough Margin based Core Vector Machine

Kobe University Repository : Kernel

Review: Support vector machines. Machine learning techniques and image analysis

Introduction to Support Vector Machines

Mehryar Mohri Foundations of Machine Learning Courant Institute of Mathematical Sciences Homework assignment 3 April 5, 2013 Due: April 19, 2013

Indirect Rule Learning: Support Vector Machines. Donglin Zeng, Department of Biostatistics, University of North Carolina

Support Vector Machine I

Support Vector Machine

Transcription:

LIBSVM: a Library for Support Vector Machines Chih-Chung Chang and Chih-Jen Lin Last updated: September 6, 2006 Abstract LIBSVM is a library for support vector machines (SVM). Its goal is to help users to easily use SVM as a tool. In this document, we present all its implementation details. For the use of LIBSVM, the README file included in the package and the LIBSVM FAQ provide the information. Introduction LIBSVM is a library for support vector machines (SVM). Its goal is to let users can easily use SVM as a tool. In this document, we present all its implementation details. For using LIBSVM, the README file included in the package provides the information. In Section 2, we show formulations used in LIBSVM: C-support vector classification (C-SVC), ν-support vector classification (ν-svc), distribution estimation (one-class SVM), ɛ-support vector regression (ɛ-svr), and ν-support vector regression (ν-svr). We discuss the implementation of solving quadratic problems in Section 3. Section 4 describes two implementation techniques: shrinking and caching. We also support different penalty parameters for unbalanced data. Details are in Section 5. Then Section 6 discusses the implementation of multi-class classification. Parameter selection is important for obtaining good SVM models. LIBSVM provides simple and useful tools, which are discussed in Section 7. Section 8 presents the implementation of probability outputs. 2 Formulations 2. C-Support Vector Classification Given training vectors x i R n, i =,..., l, in two classes, and a vector y R l such that y i,, C-SVC (Cortes and Vapnik, 995; Vapnik, 998) solves the following primal problem: w,b,ξ 2 wt w + C ξ i (2.) i= subject to y i (w T φ(x i ) + b) ξ i, ξ i 0, i =,..., l. Department of Computer Science, National Taiwan University, Taipei 06, Taiwan (http://www.csie. ntu.edu.tw/ cjlin). E-mail: cjlin@csie.ntu.edu.tw

Its dual is α 2 αt Qα e T α subject to y T α = 0, (2.2) 0 α i C, i =,..., l, where e is the vector of all ones, C > 0 is the upper bound, Q is an l by l positive semidefinite matrix, Q ij y i y j K(x i, x j ), and K(x i, x j ) φ(x i ) T φ(x j ) is the kernel. Here training vectors x i are mapped into a higher (maybe infinite) dimensional space by the function φ. The decision function is ( ) sgn y i α i K(x i, x) + b. i= 2.2 ν-support Vector Classification The ν-support vector classification (Schölkopf et al., 2000) uses a new parameter ν which controls the number of support vectors and training errors. The parameter ν (0, ] is an upper bound on the fraction of training errors and a lower bound of the fraction of support vectors. Given training vectors x i R n, i =,..., l, in two classes, and a vector y R l such that y i,, the primal form considered is: The dual is: w,b,ξ,ρ 2 wt w νρ + l i= subject to y i (w T φ(x i ) + b) ρ ξ i, ξ i ξ i 0, i =,..., l, ρ 0. α 2 αt Qα subject to 0 α i /l, i =,..., l, (2.3) e T α ν, y T α = 0. where Q ij y i y j K(x i, x j ). The decision function is: ( ) sgn y i α i (K(x i, x) + b). i= 2

In (Crisp and Burges, 2000; Chang and Lin, 200), it has been shown that e T α ν can be replaced by e T α = ν. With this property, in LIBSVM, we solve a scaled version of (2.3): α 2 αt Qα subject to 0 α i, i =,..., l, e T α = νl, y T α = 0. We output α/ρ so the computed decision function is: ( ) sgn y i (α i /ρ)(k(x i, x) + b) and then two margins are i= which are the same as those of C-SVC. y i (w T φ(x i ) + b) = ± 2.3 Distribution Estimation (One-class SVM) One-class SVM was proposed by Schölkopf et al. (200) for estimating the support of a high-dimensional distribution. Given training vectors x i R n, i =,..., l without any class information, the primal form in (Schölkopf et al., 200) is: w,b,ξ,ρ 2 wt w ρ + νl subject to w T φ(x i ) ρ ξ i, i= ξ i 0, i =,..., l. ξ i The dual is: α 2 αt Qα subject to 0 α i /(νl), i =,..., l, (2.4) where Q ij = K(x i, x j ) φ(x i ) T φ(x j ). e T α =, In LIBSVM we solve a scaled version of (2.4): 2 αt Qα subject to 0 α i, i =,..., l, e T α = νl. 3

The decision function is sgn( α i K(x i, x) ρ). i= 2.4 ɛ-support Vector Regression (ɛ-svr) Given a set of data points, (x, z ),..., (x l, z l ), such that x i R n is an input and z i R is a target output, the standard form of support vector regression (Vapnik, 998) is: w,b,ξ,ξ 2 wt w + C ξ i + C i= i= subject to w T φ(x i ) + b z i ɛ + ξ i, z i w T φ(x i ) b ɛ + ξ i, ξ i, ξ i 0, i =,..., l. ξ i The dual is: subject to α,α 2 (α α ) T Q(α α ) + ɛ (α i + αi ) + i= z i (α i αi ) (α i αi ) = 0, 0 α i, αi C, i =,..., l, (2.5) i= where Q ij = K(x i, x j ) φ(x i ) T φ(x j ). The approximate function is: ( α i + αi )K(x i, x) + b. i= 2.5 ν-support Vector Regression (ν-svr) Similar to ν-svc, for regression, Schölkopf et al. (2000) use a parameter ν to control the number of support vectors. However, unlike ν-svc, where ν replaces with C, here ν replaces with the parameter ɛ of ɛ-svr. The primal form is w,b,ξ,ξ,ɛ 2 wt w + C(νɛ + l i= (ξ i + ξi )) (2.6) i= subject to (w T φ(x i ) + b) z i ɛ + ξ i, z i (w T φ(x i ) + b) ɛ + ξ i, ξ i, ξ i 0, i =,..., l, ɛ 0. 4

and the dual is subject to α,α 2 (α α ) T Q(α α ) + z T (α α ) e T (α α ) = 0, e T (α + α ) Cν, 0 α i, α i C/l, i =,..., l, (2.7) Similarly, the inequality e T (α + α ) Cν can be replaced by an equality. In LIBSVM, we consider C C/l, so the dual problem solved is: The decision function is subject to α,α 2 (α α ) T Q(α α ) + z T (α α ) e T (α α ) = 0, e T (α + α ) = Clν, 0 α i, α i C, i =,..., l. (2.8) ( α i + αi )K(x i, x) + b, i= which is the same as that of ɛ-svr. 3 Solving the Quadratic Problems 3. The Decomposition Method for C-SVC, ɛ-svr, and One-class SVM We consider the following general form of C-SVC, ɛ-svr, and one-class SVM: α 2 αt Qα + p T α subject to y T α =, (3.) 0 α t C, t =,..., l, where y t = ±, t =,..., l. It can be clearly seen that C-SVC and one-class SVM are already in the form of (3.). For ɛ-svr, we consider the following reformulation of (2.5): α,α 2 [ α T, (α ) T ] [ Q Q Q Q ] [ α α ] + [ ɛe T + z T, ɛe T z T ] [ ] α α subject to y T [ α α ] = 0, 0 α t, α t C, t =,..., l, (3.2) where y is a 2l by vector with y t =, t =,..., l and y t =, t = l +,..., 2l. The difficulty of solving (3.) is the density of Q because Q ij is in general not zero. In LIBSVM, we consider the decomposition method to conquer this difficulty. Some work on this method are, for example, (Osuna et al., 997a; Joachims, 998; Platt, 998). This 5

method modifies only a subset of α per iteration. This subset, denoted as the working set B, leads to a small sub-problem to be imized in each iteration. An extreme case is the Sequential Minimal Optimization (SMO) (Platt, 998), which restricts B to have only two elements. Then in each iteration one solves a simple two-variable problem without needing optimization software. Here we consider an SMO-type decomposition method proposed in Fan et al. (2005). Algorithm (An SMO-type Decomposition method in Fan et al. (2005)). Find α as the initial feasible solution. Set k =. 2. If α k is a stationary point of (2.2), stop. Otherwise, find a two-element working set B = i, j by WSS (described in Section 3.2). Define N,..., l\b and α k B and α k N to be sub-vectors of αk corresponding to B and N, respectively. 3. If a ij K ii + K jj 2K ij > 0 Solve the following sub-problem with the variable α B : ] [ αi α i,α j 2 ] + (p B + Q BN α k N) T [ αi α j [ ] [ Q αi α ii Q ij j Q ij Q jj α j subject to 0 α i, α j C, (3.3) y i α i + y j α j = y T Nα k N, ] else Solve α i,α j 2 [ ] [ Q αi α ii Q ij j Q ij Q jj ] [ αi + τ a ij ((α i αi k ) 2 + (α j αj k ) 2 ) 4 subject to constraints of (3.3). α j ] [ ] + (p B + Q BN α k N) T αi α j (3.4) 4. Set α k+ B to be the optimal solution of (3.3) and α k+ N αk N. Set k k + and goto Step 2. Note that B is updated at each iteration. To simplify the notation, we simply use B instead of B k. If a ij 0, (3.3) is a concave problem. Hence we use a convex modification in (3.4). 6

3.2 Stopping Criteria and Working Set Selection for C-SVC, ɛ-svr, and One-class SVM The Karush-Kuhn-Tucker (KKT) optimality condition of (3.) shows that a vector α is a stationary point of (3.) if and only if there is a number b and two nonnegative vectors λ and µ such that f(α) + by = λ µ, λ i α i = 0, µ i (C α i ) = 0, λ i 0, µ i 0, i =,..., l, where f(α) Qα + p is the gradient of f(α). This condition can be rewritten as Since y i = ±, by defining f(α) i + by i 0 if α i < C, (3.5) f(α) i + by i 0 if α i > 0. (3.6) I up (α) t α t < C, y t = or α t > 0, y t =, and I low (α) t α t < C, y t = or α t > 0, y t =, (3.7) a feasible α is a stationary point of (3.) if and only if where m(α) m(α) M(α), (3.8) max y i f(α) i, and M(α) y i f(α) i. i I up(α) i I low (α) From this we have the following stopping condition: m(α k ) M(α k ) ɛ. (3.9) About the selection of the working set set B, we consider the following procedure: WSS. For all t, s, define a ts K tt + K ss 2K ts, b ts y t f(α k ) t + y s f(α k ) s > 0 (3.0) and Select ats if a ā ts ts > 0, τ otherwise. (3.) i arg max y t f(α k ) t t I up (α k ), j arg t t b2 it ā it t I low (α k ), y t f(α k ) t < y i f(α k ) i. (3.2) 7

2. Return B = i, j. Details of how we choose this working set is in (Fan et al., 2005, Section II). 3.3 Convergence of the Decomposition Method See (Fan et al., 2005, Section III) or (Chen et al., 2006) for a detailed discussion of the convergence of Algorithm. 3.4 The Decomposition Method for ν-svc and ν-svr Both ν-svc and ν-svr can be considered as the following general form: The KKT condition of (3.3) shows α 2 αt Qα + p T α subject to y T α =, (3.3) e T α = 2, 0 α t C, t =,..., l. f(α) i ρ + by i = 0 if 0 < α i < C, 0 if α i = 0, 0 if α i = C. Define r ρ b, r 2 ρ + b. If y i = the KKT condition becomes f(α) i r 0 if α i < C, (3.4) 0 if α i > 0. On the other hand, if y i =, it is f(α) i r 2 0 if α i < C, (3.5) 0 if α i > 0. Hence given a tolerance ɛ > 0, the stopping condition is: max ( i + max i, α i <C,y i = α i >0,y i = i + max ) i < ɛ. α i <C,y i = α i >0,y i = The working set selection is by extending WSS to the following 8

WSS 2 (Extending WSS to ν-svm). Find 2. Find i p arg m p (α k ), j p arg t i n arg m n (α k ), j n arg t b2 i pt ā ipt b2 i nt ā int y t =, α t I low (α k ), y t f(α k ) t < y ip f(α k ) ip y t =, α t I low (α k ), y t f(α k ) t < y in f(α k ) in.. 3. Return i p, j p ) or i n, j n depending on which one gives smaller b 2 ij /ā ij. 3.5 Analytical Solutions Details are described in Section 5 in which we discuss the solution of a more general subproblem. 3.6 The Calculation of b or ρ After the solution α of the dual optimization problem is obtained, the variables b or ρ must be calculated as they are used in the decision function. Here we simply describe the case of ν-svc and ν-svr where b and ρ both appear. Other formulations are simplified cases of them. The KKT condition of (3.3) has been shown in (3.4) and (3.5). Now we consider the case of y i =. If there are α i which satisfy 0 < α i < C, then r = f(α) i. Practically to avoid numerical errors, we average them: 0<α r = i <C,y i = f(α) i 0<α i <C,y i =. On the other hand, if there is no such α i, as r must satisfy we take r the midpoint of the range. max f(α) i r f(α) i, α i =C,y i = α i =0,y i = For y i =, we can calculate r 2 in a similar way. After r and r 2 are obtained, ρ = r + r 2 2 and b = r r 2. 2 9

4 Shrinking and Caching 4. Shrinking Since for many problems the number of free support vectors (i.e. 0 < α i < C) is small, the shrinking technique reduces the size of the working problem without considering some bounded variables (Joachims, 998). Near the end of the iterative process, the decomposition method identifies a possible set A where all final free α i may reside in. Indeed we can have the following theorem which shows that at the final iterations of the decomposition proposed in Section 3.2 only variables corresponding to a small set are still allowed to move: Theorem 4. (Theorem IV in (Fan et al., 2005)) Assume Q is positive semi-definite.. The following set is independent of any optimal solution ᾱ: I i y i f(ᾱ) i > M(ᾱ) or y i f(ᾱ) i < m(ᾱ). (4.) Problem (2.2) has unique and bounded optimal solutions at α i, i I. 2. Assume Algorithm generates an infinite sequence α k. There is k such that after k k, every αi k, i I has reached the unique and bounded optimal solution. It remains the same in all subsequent iterations and k k: i t M(α k ) y t f(α k ) t m(α k ). (4.2) Hence instead of solving the whole problem (2.2), the decomposition method works on a smaller problem: 2 αt AQ AA α A (p A Q AN α k N) T α A subject to 0 (α A ) t C, t =,..., q, (4.3) α A yaα T A = ynα T k N, where N =,..., l\a is the set of shrunken variables. Of course this heuristic may fail if the optimal solution of (4.3) is not the corresponding part of that of (2.2). When that happens, the whole problem (2.2) is reoptimized starting from a point α where α A is an optimal solution of (4.3) and α N are bounded variables identified before the shrinking process. Note that while solving the shrunken problem (4.3), we only know the gradient Q AA α A + Q AN α N + p A of (4.3). Hence when problem (2.2) is reoptimized we also have to reconstruct the whole gradient f(α), which is quite expensive. 0

Many implementations began the shrinking procedure near the end of the iterative process, in LIBSVM however, we start the shrinking process from the beginning. The procedure is as follows:. After every (l, 000) iterations, we try to shrink some variables. Note that during the iterative process m(α k ) > M(α k ) (4.4) as (3.9) is not satisfied yet. Following Theorem 4., we conjecture that variables in the following set can be shrunken: t t > m(α k ), t I low (α k ), αt k is bounded t t < M(α k ), t I up (α k ), αt k is bounded = t t > m(α k ), αt k = C, y t = or αt k = 0, y t = t t < M(α k ), αt k = 0, y t = or αt k = C, y t =. (4.5) Thus the set A of activated variables is dynamically reduced in every (l, 000) iterations. 2. Of course the above shrinking strategy may be too aggressive. Since the decomposition method has a very slow convergence and a large portion of iterations are spent for achieving the final digit of the required accuracy, we would not like those iterations are wasted because of a wrongly shrunken problem (4.3). Hence when the decomposition method first achieves the tolerance m(α k ) M(α k ) + 0ɛ, where ɛ is the specified stopping criteria, we reconstruct the whole gradient. Then we inactive some variables based on the current set (4.5). and the decomposition method continues. Therefore, in LIBSVM, the size of the set A of (4.3) is dynamically reduced. To decrease the cost of reconstructing the gradient f(α), during the iterations we always keep Ḡ i = C Q ij, i =,..., l. α j =C Then for the gradient f(α) i, i / A, we have f(α) i = Q ij α j + p i = Ḡi + Q ij α j + p i. j= 0<α j <C

For ν-svc and ν-svr, as the stopping condition (3.6) is different from (3.9), the set (4.5) must be modified. For y t =, we shrink elements in the following set t t > m(α k ), α t = 0, y t = t t < M(α k ), α t = C, y t =. The set for y t = is similar. 4.2 Caching Another technique for reducing the computational time is caching. Since Q is fully dense and may not be stored in the computer memory, elements Q ij are calculated as needed. Then usually a special storage using the idea of a cache is used to store recently used Q ij (Joachims, 998). Hence the computational cost of later iterations can be reduced. Theorem 4. also supports the use of the cache as in final iterations only some columns of the matrix Q are still needed. Thus if the cache can contain these columns, we can avoid most kernel evaluations in final iterations. In LIBSVM, we implement a simple least-recent-use strategy for the cache. We dynamically cache only recently used columns of Q AA of (4.3). 4.3 Computational Complexity The discussion in Section 3.3 is about the asymptotic convergence of the decomposition method. Here, we discuss the computational complexity. The main operations are on finding Q BN α k N + p B of (3.3) and the update of f(α k ) to f(α k+ ). Note that f(α) is used in the working set selection as well as the stopping condition. They can be considered together as Q BN α k N + p B = f(α k ) Q BB α k B, (4.6) and f(α k+ ) = f(α k ) + Q :,B (α k+ B αk B), (4.7) where Q :,B is the sub-matrix of Q with column in B. That is, at the kth iteration, as we already have f(α k ), the right-hand-side of (4.6) is used to construct the sub-problem. After the sub-problem is solved, (4.7) is employed to have the next f(α k+ ). As B has only two elements and solving the sub-problem is easy, the main cost is Q :,B (α k+ B αk B ) of (4.7). The operation itself takes O(2l) but if Q :,B is not available in the cache and each kernel evaluation costs O(n), one column indexes of Q :,B already needs O(ln). Therefore, the complexity is:. #Iterations O(l) if most columns of Q are cached during iterations. 2

2. #Iterations O(nl) if most columns of Q are cached during iterations and each kernel evaluation is O(n). Note that if shrinking is incorporated, l will gradually decrease during iterations. 5 Unbalanced Data For some classification problems, numbers of data in different classes are unbalanced. Hence some researchers (e.g. (Osuna et al., 997b)) have proposed to use different penalty parameters in the SVM formulation: For example, C-SVM becomes Its dual is w,b,ξ 2 wt w + C + y i = ξ i + C subject to y i (w T φ(x i ) + b) ξ i, ξ i 0, i =,..., l. y i = α 2 αt Qα e T α subject to 0 α i C +, if y i =, (5.) 0 α i C, if y i =, (5.2) y T α = 0. Note that by replacing C with different C i, i =,..., l, most of the analysis earlier are still correct. Now using C + and C is just a special case of it. Therefore, the implementation is almost the same. A main difference is on the solution of the sub-problem (3.3). Now it becomes: α i,α j 2 [ ] [ Q αi α ii Q ij j Q ji Q jj ] [ αi α j ] + (Q i,n α N )α i + (Q j,n α N )α j subject to y i α i + y j α j = y T Nα k N, (5.3) 0 α i C i, 0 α j C j, where C i and C j can be C + or C depending on y i and y j. Let α i = α k i + d i, α j = α k j + d j and ˆd i y i d i, ˆd j y j d j. Then (5.3) can be written as [ ] [ ] [ ] Q di d ii Q ij di j + [ f(α d i,d j 2 Q ij Q jj d k ) i f(α k ] [ ] d ) i j j d j subject to y i d i + y j d j = 0, (5.4) α k i d i C α k i, α k j d j C α k j. ξ i 3

Define a ij and b ij as in (3.0). Note that if a ij 0, then a modification similar to (3.4). Using ˆd i = ˆd j, the objective function can be written as Thus, 2āij ˆd 2 j + b ij ˆdj. α new i = α k i + y i b ij /ā ij, α new j = α k i y j b ij /ā ij. (5.5) To modify them back to the feasible region, we first consider the case y i y j and write (5.5) as If α new is not feasible, (α new i α new i = α k i + ( f(α k ) i f(α k ) j )/ā ij, α new j = α k i + ( f(α k ) i f(α k ) j )/ā ij., αj new ) is in one of the following four regions: α j II IV I If it is in region I, α k+ i III is set to be C i first and then α i α k+ j = C i (α k i α k j ). Of course we must check if it is in region I first. If so, we have α k i α k j > C i C j and α new i C i. Other cases are similar. Therefore, we have the following procedure to identify (αi new, αj new ) in different regions and change it back to the feasible set. if(y[i]!=y[j]) double quad_coef = Q_i[i]+Q_j[j]+2*Q_i[j]; if (quad_coef <= 0) quad_coef = TAU; double delta = (-G[i]-G[j])/quad_coef; double diff = alpha[i] - alpha[j]; 4

alpha[i] += delta; alpha[j] += delta; if(diff > 0) if(alpha[j] < 0) else alpha[j] = 0; alpha[i] = diff; // in region III if(alpha[i] < 0) // in region IV alpha[i] = 0; alpha[j] = -diff; if(diff > C_i - C_j) else if(alpha[i] > C_i) // in region I alpha[i] = C_i; alpha[j] = C_i - diff; if(alpha[j] > C_j) // in region II alpha[j] = C_j; alpha[i] = C_j + diff; 6 Multi-class classification We use the one-against-one approach (Knerr et al., 990) in which k(k )/2 classifiers are constructed and each one trains data from two different classes. The first use of this strategy on SVM was in (Friedman, 996; Kreßel, 999). For training data from the ith 5

and the jth classes, we solve the following two-class classification problem: w ij,b ij,ξ ij 2 (wij ) T w ij + C( (ξ ij ) t ) t subject to (w ij ) T φ(x t ) + b ij ξ ij t, if x t in the ith class, (w ij ) T φ(x t ) + b ij + ξ ij t, if x t in the jth class, ξ ij t 0. In classification we use a voting strategy: each binary classification is considered to be a voting where votes can be cast for all data points x - in the end point is designated to be in a class with maximum number of votes. In case that two classes have identical votes, though it may not be a good strategy, now we simply select the one with the smallest index. There are other methods for multi-class classification. Some reasons why we choose this -against- approach and detailed comparisons are in Hsu and Lin (2002). 7 Parameter Selection LIBSVM provides a parameter selection tool using the RBF kernel: cross validation via parallel grid search. Currently, we support only C-SVC where two parameters are considered: C and γ. They can be easily modified for other kernels such as linear and polynomial. For median-sized problems, cross validation might be the most reliable way for parameter selection. First, the training data is separated to several folds. Sequentially a fold is considered as the validation set and the rest are for training. The average of accuracy on predicting the validation sets is the cross validation accuracy. Our implementation is as follows. Users provide a possible interval of C (or γ) with the grid space. Then, all grid points of (C, γ) are tried to see which one gives the highest cross validation accuracy. Users then use the best parameter to train the whole training set and generate the final model. For easy implementation, we consider each SVM with parameters (C, γ) as an independent problem. As they are different jobs, we can easily solve them in parallel. Currently, LIBSVM provides a very simple tool so that jobs are dispatched to a cluster of computers which share the same file system. Note that now under the same (C, γ), the one-against-one method is used for training multi-class data. Hence, in the final model, all k(k )/2 decision functions share the same (C, γ). 6

Figure : Contour plot of heart scale included in the LIBSVM package LIBSVM also outputs the contour plot of cross validation accuracy. An example is in Figure. 8 Probability Estimates Support vector classification (regression) predicts only class label (approximate target value) but not probability information. In the following we briefly describe how we extend SVM for probability estimates. More details are in Wu et al. (2004) for classification and in Lin and Weng (2004) for regression. Given k classes of data, for any x, the goal is to estimate p i = p(y = i x), i =,..., k. Following the setting of the one-against-one (i.e., pairwise) approach for multi-class classification, we first estimated pairwise class probabilities r ij p(y = i y = i or j, x) 7

using an improved implementation (Lin et al., 2003) of (Platt, 2000): r ij, (8.) + ea ˆf+B where A and B are estimated by imizing the negative log-likelihood function using known training data and their decision values ˆf. Labels and decision values are required to be independent so here we conduct five-fold cross-validation to obtain decision values. Then the second approach in Wu et al. (2004) is used to obtain p i from all these r ij s. It solves the following optimization problem: p 2 k (r ji p i r ij p j ) 2 subject to i= j:j i k p i =, p i 0, i. (8.2) i= The objective function comes from the equality p(y = j y = i or j, x) p(y = i x) = p(y = i y = i or j, x) p(y = j x) and can be reformulated as where Q ij = p 2 pt Qp, (8.3) s:s i r2 si if i = j, r ji r ij if i j. (8.4) This problem is convex, so the optimality conditions that there is a scalar b such that [ ] [ ] [ ] Q e p 0 e T =. (8.5) 0 b Here e is the k vector of all ones, 0 is the k vector of all zeros, and b is the Lagrangian multiplier of the equality constraint k i= p i =. Instead of directly solving the linear system (8.5), we derive a simple iterative method in the following. As p T Qp = p T Q( bq e) = bp T e = b, the solution p satisfies Q tt p t + Q tj p j p T Qp = 0, for any t. (8.6) j:j t Using (8.6), we consider the following algorithm: Algorithm 2. Start with some initial p i 0, i and k i= p i =. 8

2. Repeat (t =,..., k,,...) p t Q tt [ j:j t Q tj p j + p T Qp] (8.7) normalize p (8.8) until (8.5) is satisfied. This procedure guarantees to find a global optimum of (8.2). Using some tricks, we do not need to recalculate p T Qp in each iteration. Detailed implementation notes are in Appendix C of Wu et al. (2004). We consider a relative stopping condition for Algorithm 2: Qp p T Qpe = max (Qp) t p T Qp < 0.005/k. t When k is large, p will be closer to zero, so we decrease the tolerance by a factor of k. Next, we discuss SVR probability inference. For a given set of training data D = (x i, y i ) x i R n, y i R, i =,..., l, we suppose that the data are collected from the model: y i = f(x i ) + δ i, (8.9) where f(x) is the underlying function and δ i are independent and identically distributed random noises. Given a test data x, the distribution of y given x and D, P (y x, D), allows one to draw probabilistic inferences about y; for example, one can construct a predictive interval I = I(x) such that y I with a pre-specified probability. Denoting ˆf as the estimated function based on D using SVR, then ζ = ζ(x) y ˆf(x) is the out-of-sample residual (or prediction error), and y I is equivalent to ζ I ˆf(x). We propose to model the distribution of ζ based on a set of out-of-sample residuals ζ i l i= using training data D. The ζ i s are generated by first conducting a k-fold cross validation to get ˆf j, j =,..., k, and then setting ζ i y i ˆf j (x i ) for (x i, y i ) in the jth fold. It is conceptually clear that the distribution of ζ i s may resemble that of the prediction error ζ. Figure 2 illustrates ζ i s from a real data. Basically, a discretized distribution like histogram can be used to model the data; however, it is complex because all ζ i s must be retained. On the contrary, distributions like Gaussian and Laplace, commonly used as noise models, require only location and scale parameters. In Figure 2 we plot the fitted curves using these two families and the histogram of ζ i s. The figure shows that the distribution of ζ i s seems symmetric about zero and that both Gaussian and Laplace reasonably capture the shape of ζ i s. Thus, we propose to model ζ i by zero-mean Gaussian and Laplace, or equivalently, model the conditional distribution of y given ˆf(x) by Gaussian and Laplace with mean ˆf(x). 9

(Lin and Weng, 2004) discussed a method to judge whether a Laplace and Gaussian distribution should be used. Moreover, they experimentally show that in all cases they have tried, Laplace is better. Thus, here we consider the zero-mean Laplace with a density function: p(z) = z 2σ e σ. (8.0) Assug that ζ i are independent, we can estimate the scale parameter by maximizing the likelihood. For Laplace, the maximum likelihood estimate is σ = l i= ζ i. (8.) l (Lin and Weng, 2004) pointed out that some very extreme ζ i may cause inaccurate estimation of σ. Thus, they propose to estimate the scale parameter by discarding ζ i s which exceed ±5 (standard deviation of ζ i ). Thus, for any new data x, we consider that y = ˆf(x) + z, where z is a random variable following the Laplace distribution with parameter σ. In theory, the distribution of ζ may depend on the input x, but here we assume that it is free of x. This is similar to the model (8.) for classification. Such an assumption works well in practice and leads to a simple model. Figure 2: Histogram of ζ i s from a data set and the modeling via Laplace and Gaussian distributions. The x-axis is ζ i using five-fold CV and the y-axis is the normalized number of data in each bin of width. 20

Acknowledgments This work was supported in part by the National Science Council of Taiwan via the grants NSC 89-223-E-002-03 and NSC 89-223-E-002-06. The authors thank Chih-Wei Hsu and Jen-Hao Lee for many helpful discussions and comments. We also thank Ryszard Czerski and Lily Tian for some useful comments. References C.-C. Chang and C.-J. Lin. Training ν-support vector classifiers: Theory and algorithms. Neural Computation, 3(9):29 247, 200. P.-H. Chen, R.-E. Fan, and C.-J. Lin. A study on SMO-type decomposition methods for support vector machines. IEEE Transactions on Neural Networks, 2006. URL http: //www.csie.ntu.edu.tw/ cjlin/papers/generalsmo.pdf. To appear. C. Cortes and V. Vapnik. Support-vector network. Machine Learning, 20:273 297, 995. D. J. Crisp and C. J. C. Burges. A geometric interpretation of ν-svm classifiers. In S. Solla, T. Leen, and K.-R. Müller, editors, Advances in Neural Information Processing Systems, volume 2, Cambridge, MA, 2000. MIT Press. R.-E. Fan, P.-H. Chen, and C.-J. Lin. Working set selection using second order information for training SVM. Journal of Machine Learning Research, 6:889 98, 2005. URL http://www.csie.ntu.edu.tw/ cjlin/papers/quadworkset.pdf. J. Friedman. Another approach to polychotomous classification. Technical report, Department of Statistics, Stanford University, 996. Available at http://www-stat.stanford.edu/reports/friedman/poly.ps.z. C.-W. Hsu and C.-J. Lin. A comparison of methods for multi-class support vector machines. IEEE Transactions on Neural Networks, 3(2):45 425, 2002. T. Joachims. Making large-scale SVM learning practical. In B. Schölkopf, C. J. C. Burges, and A. J. Smola, editors, Advances in Kernel Methods - Support Vector Learning, Cambridge, MA, 998. MIT Press. S. Knerr, L. Personnaz, and G. Dreyfus. Single-layer learning revisited: a stepwise procedure for building and training a neural network. In J. Fogelman, editor, Neurocomputing: Algorithms, Architectures and Applications. Springer-Verlag, 990. 2

U. Kreßel. Pairwise classification and support vector machines. In B. Schölkopf, C. J. C. Burges, and A. J. Smola, editors, Advances in Kernel Methods Support Vector Learning, pages 255 268, Cambridge, MA, 999. MIT Press. C.-J. Lin and R. C. Weng. Simple probabilistic predictions for support vector regression. Technical report, Department of Computer Science, National Taiwan University, 2004. URL http://www.csie.ntu.edu.tw/ cjlin/papers/svrprob.pdf. H.-T. Lin, C.-J. Lin, and R. C. Weng. A note on Platt s probabilistic outputs for support vector machines. Technical report, Department of Computer Science, National Taiwan University, 2003. URL http://www.csie.ntu.edu.tw/ cjlin/papers/plattprob.ps. E. Osuna, R. Freund, and F. Girosi. Training support vector machines: An application to face detection. In Proceedings of CVPR 97, pages 30 36, New York, NY, 997a. IEEE. E. Osuna, R. Freund, and F. Girosi. Support vector machines: Training and applications. AI Memo 602, Massachusetts Institute of Technology, 997b. J. Platt. Probabilistic outputs for support vector machines and comparison to regularized likelihood methods. In A. Smola, P. Bartlett, B. Schölkopf, and D. Schuurmans, editors, Advances in Large Margin Classifiers, Cambridge, MA, 2000. MIT Press. URL citeseer. nj.nec.com/platt99probabilistic.html. J. C. Platt. Fast training of support vector machines using sequential imal optimization. In B. Schölkopf, C. J. C. Burges, and A. J. Smola, editors, Advances in Kernel Methods - Support Vector Learning, Cambridge, MA, 998. MIT Press. B. Schölkopf, A. Smola, R. C. Williamson, and P. L. Bartlett. New support vector algorithms. Neural Computation, 2:207 245, 2000. B. Schölkopf, J. C. Platt, J. Shawe-Taylor, A. J. Smola, and R. C. Williamson. Estimating the support of a high-dimensional distribution. Neural Computation, 3(7):443 47, 200. V. Vapnik. Statistical Learning Theory. Wiley, New York, NY, 998. T.-F. Wu, C.-J. Lin, and R. C. Weng. Probability estimates for multi-class classification by pairwise coupling. Journal of Machine Learning Research, 5:975 005, 2004. URL http://www.csie.ntu.edu.tw/ cjlin/papers/svmprob/svmprob.pdf. 22