Large-Scale SVM Learning Techniques
Large-Scale SVM Learning Techniques
Thorsten Joachims
Universitat Dortmund, Informatik, AI-Unit
Thorsten Joachims@[Link]
[Link]
To be published in: 'Advances in Kernel Methods - Support Vector Learning',
Bernhard Scholkopf, Christopher J. C. Burges, and Alexander J. Smola (eds.),
MIT Press, Cambridge, USA, 1998.
Training a support vector machine (SVM) leads to a quadratic optimization
problem with bound constraints and one linear equality constraint. Despite the
fact that this type of problem is well understood, there are many issues to be
considered in designing an SVM learner. In particular, for large learning tasks with
many training examples, o-the-shelf optimization techniques for general quadratic
programs quickly become intractable in their memory and time requirements.
SV M light 1 is an implementation of an SVM learner which addresses the problem of
large tasks. This chapter presents algorithmic and computational results developed
for SV M light V2.0, which make large-scale SVM training more practical. The results
give guidelines for the application of SVMs to large domains.
11.1 Introduction
Chapter 1 and Vapnik (1995) show how training a support vector machine for the
pattern recognition problem leads to the following quadratic optimization problem
(QP) OP1.
X̀ X̀ X̀
(OP1) minimize: W () = , i + 21 yi yj ij k(xi ; xj ) (11.1)
i=1 i=1 j =1
X̀
subject to: yi i = 0 (11.2)
i=1
8i : 0 i C (11.3)
0 C1 (11.6)
The size of the optimization problem depends on the number of training examples
`. Since the size of the matrix Q is `2 , for learning tasks with 10000 training
examples and more it becomes impossible to keep Q in memory. Many standard
implementations of QP solvers require explicit storage of Q which prohibits their
application. An alternative would be to recompute Q every time it is needed. But
this becomes prohibitively expensive, if Q is needed often.
One approach to making the training of SVMs on problems with many training
examples tractable is to decompose the problem into a series of smaller tasks.
SV M light uses the decomposition idea of Osuna et al. (1997b). This decomposition
splits OP1 in an inactive and an active part - the so call \working set". The
main advantage of this decomposition is that it suggests algorithms with memory
requirements linear in the number of training examples and linear in the number of
SVs. One potential disadvantage is that these algorithms may need a long training
time. To tackle this problem, this chapter proposes an algorithm which incorporates
the following ideas:
An ecient and eective method for selecting the working set.
Successive \shrinking" of the optimization problem. This exploits the property
that many SVM learning problems have
much less support vectors (SVs) than training examples.
many SVs which have an i at the upper bound C .
Computational improvements like caching and incremental updates of the gradi-
ent and the termination criteria.
This chapter is structured as follows. First, a generalized version of the decom-
positon algorithm of Osuna et al. (1997a) is introduced. This identies the problem
of selecting the working set, which is addressed in the following section. In sec-
tion 11.4 a method for \shrinking" OP1 is presented and section 11.5 describes the
computational and implementational approach of SV M light . Finally, experimental
results on two benchmark tasks, a text classication task, and an image recognition
task are discussed to evaluate the approach.
8i 2 [1::n] : up
i (i , C ) =0 (11.9)
lo 0 (11.10)
up 0 (11.11)
yT =0 (11.12)
0 C1 (11.13)
QP-Subproblems If the optimality conditions do not hold, the algorithm decomposes OP1 and
solves the smaller QP-problem arising from this. The decomposition assures that
this will lead to progress in the objective function W (), if the working set B
fullls some minimum requirements (see Osuna et al. (1997b)). In particular, OP1
is decomposed by separating the variables in the working set B from those which
are xed (N ). Let's assume , y, and Q are properly arranged with respect to B
and N , so that
= B
y
y = B Q = QBB Q BN
N yN QNB QNN
(11.15)
0 C1 (11.18)
Since the variables in N are xed, the terms 12 TN QNN N and ,TN 1 are
constant. They can be omitted without changing the solution of OP2. OP2 is a
positive semidenite quadratic programming problem which is small enough be
solved by most o-the-shelf methods. It is easy to see that changing the i in
the working set to the solution of OP2 is the optimal step on B . So fast progress
depends heavily on whether the algorithm can select good working sets.
subject to: T
y d=0 (11.20)
di 0 for i: i = 0 (11.21)
di 0 for i: i = C (11.22)
,1 d 1 (11.23)
it would be sucient to train just on those examples and still get to the same result.
This would make OP1 smaller and faster to solve, since we could save time and
space by not needing parts of the Hessian Q which do not correspond to SVs.
Similarly, for noisy problems there are often many SVs with an i at the upper
bound C . Let's call these support vectors \bounded support vectors" (BSVs).
Similar arguments as for the non-support vectors apply to BSVs. If it was known a
priori which of the training examples turn out as BSVs, the corresponding i could
be xed at C leading to a new optimization problem with fewer variables.
During the optimization process it often becomes clear fairly early that certain
examples are unlikely to end up as SVs or that they will be BSVs. By eliminating
these variables from OP1, we get a smaller problem OP1' of size `0 . From OP1' we
can construct the solution of OP1. Let X denote those indices corresponding to
unbounded support vectors, Y those indexes which correspond to BSVs, and Z the
indices of non-support vectors. The transformation from OP1 to OP1' can be done
using a decomposition similar to (11.16). Let's assume , y, and Q are properly
arranged with respect to X , Y , and Z , so that we can write
X X yX QXX QXY QXZ
= Y = C 1 y = yY Q = QY X QY Y QY Z (11.25)
Z 0 yZ QZX QZY QZZ
The decomposition of W () is
minimize: W (X ) = ,TX (1 , (QXY 1) C ) + 21 TX QXX X +
1 C 1T Q C 1 , jY jC
2 YY (11.26)
0 X C 1 (11.28)
upper and the lower bound simultanously, the multipliers of the bound constraints
can now be estimated by
02 3 1
X̀
loi = yi @4 j yj k(xi ; xj)5 + eq A , 1 (11.30)
j =1
for the lower bounds and by
02 3 1
X̀
i = ,yi @4 j yj k(xi ; xj)5 + A + 1
up eq (11.31)
j =1
for the upper bounds. Let's consider the history of the Lagrange multiplier estimates
over the last h iterations. If the estimate (11.30) or (11.31) was positive (or above
some threshold) at each of the last h iterations, it is likely that this will be true at
the optimal solution, too. These variables are eliminated using the decomposition
from above. This means that these variables are xed and neither the gradient, nor
the optimality conditions are computed. This leads to a substantial reduction in
the number of kernel evaluations.
Since this heuristic can fail, the optimality conditions for the excluded variables
are checked after convergence of OP1'. If necessary, the full problem is reoptimized
starting from the solution of OP1'.
y=0
T (11.35)
The optimality conditions (11.32), (11.33), and (11.34) are very natural since
they re
ect the constraints of the original optimization problem (11.40). In practice
these conditions need not be fullled with high accuracy. Using a tolerance of
= 0:001 is acceptable for most tasks. Using a higher accuracy did not show
improved generalization performance on the tasks tried, but lead to considerably
longer training time.
11.5.2 Computing the Gradient and the Termination Criteria Eciently
The eciency of the optimization algorithm greatly depends on how eciently the
\housekeeping" in each iteration can be done. The following quantities are needed
in each iteration.
The vector of partial derivatives g((t) ) for selecting the working set.
The values of the expressions (11.32), (11.33), and (11.34) for the termination
criterion.
The matrices QBB and QBN for the QP subproblem.
Fortunately, due to the decompositon approach, all these quantities can be com-
puted or updated knowing only q rows of the Hessian Q. These q rows correspond to
the variables in the current working set. The values in these rows are computed di-
rectly after the working set is selected and they are stored throughout the iteration.
It is useful to introduce s(t)
X̀
s(it) = j yj k(xi ; xj) (11.36)
j =1
Knowing s(t), the gradient (11.14) as well as in the termination criteria (11.32)-
(11.34) can be computed very eciently. When (t,1) changes to (t) the vector
s(t) needs to be updated. This can be done eciently and with sucient accuracy
as follows
X
s(it) = s(it,1) + ((jt) , (jt,1))yj k(xi ; xj ) (11.37)
j 2B
Note that only those rows of Q are needed which correspond to variables in the
working set. The same is true for QBB and QBN , which are merely subsets of
columns from these rows.
11.5.3 What are the Computational Resources Needed in each Iteration?
Time Complexity Most time in each iteration is spent on the kernel evaluations needed to compute
the q rows of the Hessian. This step has a time complexity of O(qlf ), where f is the
maximum number of non-zero features in any of the training examples. Using the
stored rows of Q, updating s(t) is done in time O(ql). Setting up the QP subproblem
requires O(ql) as well. Also the selection of the next working set, which includes
computing the gradient, can be done in O(ql).
Space Complexity The highest memory requirements are due to storing the q rows of Q. Here O(ql)
oating point numbers need to be stored. Besides this, O(q2 ) is needed to store
QBB and O(l) to store s(t).
11.5.4 Caching Kernel Evaluations
As pointed out in the last section, the most expensive step in each iteration is
the evaluation of the kernel to compute the q rows of the Hessian Q. Throughout
the optimization process, eventual support vectors enter the working set multiple
times. To avoid recomputation of these rows, SV M light uses caching. This allows
an elegant trade-o between memory consumption and training time.
SV M light uses a least-recently-used caching strategy. When the cache is full, the
element which has not been used for the greatest number of iterations, is removed
to make room for the current row.
Only those columns are computed and cached which correspond to active vari-
ables. After shrinking, the cache is reorganized accordingly.
11.5.5 How to Solve OP2 (QP Subproblems)
Currently a primal-dual interior-point solver (see Vanderbei (1994)) implemented
by A. Smola is used to solve the QP subproblems OP2. Nevertheless, other opti-
mizers can easily be incorporated into SV M light as well.
11.7 Experiments
The following experiments evaluate the approach on four datasets. The experiments
are conducted on a SPARC Ultra/167Mhz with 128MB of RAM running Solaris II.
If not stated otherwise, in the following experiments the cache size is 80 megabytes,
the number of iterations h for the shrinking heuristic is 100, and OP1 is solved up
to a precision of = 0:001 in (11.32)-(11.34).
11.7.1 How does Training Time Scale with the Number of Training
Examples?
[Link] Income Prediction
This task was compiled by John Platt (see Platt (1998)) from the UCI \adult" data
set. The goal is to predict whether a household has an income greater than $50,000.
After discretization of the continuous attributes, there are 123 binary features. On
average, there are 14 non-zero attributes per example.
Table 11.1 and the left graph in gure 11.1 show training times for an RBF-kernel
(11.38) with = 10 and C = 1. The results for SMO and Chunking are taken from
Platt (1998). When comparing absolute training times, one should keep in mind
that SMO and Chunking were run on a faster computer (266Mhz Pentium II)2 .
Both SV M light and SMO are substantially faster than the conventional chunking
algorithm, whereas SV M light is about twice as fast as SMO. The best working set
size is q = 2. By tting lines to the log-log plot we get an empirical scaling of `2:1
for both SV M light and SMO. The scaling of the chunking algorithm is `2:9 .
The column \minimum" gives a lower bound on the training time. This bound
makes the conjecture that in the general case any optimization algorithms needs to
chunking chunking
SMO SMO
7000 SVM-Light 3500 SVM-Light
minimum minimum
6000 3000
CPU-time in seconds
CPU-time in seconds
5000 2500
4000 2000
3000 1500
2000 1000
1000 500
0 0
0 5000 10000 15000 20000 25000 30000 35000 0 5000 10000 15000 20000 25000 30000 35000 40000 45000 50000
Number of examples Number of examples
Figure 11.1 Training times from tables 11.1 (left) and 11.2 (right) as graphs.
at least once look at the rows of the Hessian Q which correspond to the support
vectors. The column \minimum" shows the time to compute those rows once
(exploiting symmetry). This time scales with `2:0, showing the complexity inherent
in the classication task. For the training set sizes considered, SV M light is both
close to this minimum scaling as well as within a factor of approximately two in
terms of absolute runtime.
[Link] Classifying Web Pages
The second data set - again compiled by John Platt (see Platt (1998)) - is a text
classication problem with a binary representation based on 300 keyword features.
This representation is extremely sparse. On average there are only 12 non-zero
features per example.
Table 11.2 shows training times on this data set for an RBF-kernel (11.38) with
= 10 and C = 5. Again, the times for SMO and Chunking are taken from Platt
(1998). SV M light is faster than SMO and Chunking on this data set as well, scaling
with `1:7. The best working set size is q = 2.
Table 11.3 shows that this tasks involves many SVs which are not at the upper
bound. Relative to this high number of SVs the cache size is small. To avoid
frequent recomputations of the same part of the Hessian Q, an additional heuristic
is incorporated here. The working set is selected with the constraint that at least
for half of the selected variables the kernel values are already cached. Unlike for the
previous tasks, optimum performance is achieved with a working set size of q = 20.
For the training set sizes considered here, runtime is within a factor of 4 from the
minimum.
[Link] Dectecting Faces in Images
In this last problem the task is to classify images according to whether they contain
a human face or not. The data set was collected by Shumeet Baluja. The images
consist of 20x20 pixels of continuous gray values. So the average number of non-zero
attributes per example is 400. An RBF-kernel with = 7:1 and C = 10 is used.
The working set size is q = 20.
Table 11.4 shows the training time (in seconds). For this task, the training time
is very close to the minimum. This shows that the working set selection strategy
is very well suited for avoiding unnecessary kernel evaluations. The scaling is very
close to the optimum scaling.
Let's now evaluate, how particular strategies of the algorithm in
uence the
performance.
90 45
80 40
70 35
60 30
CPU-time in minutes
CPU-time in minutes
50 25
40 20
30 15
20 10
10 5
0 0
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80
Size of working set Cache-size in MB
Figure 11.2 Training time dependent on working set size and cache size for the
Ohsumed task.
11.7.2 What is the In
uence of the Working Set Selection Strategy?
Working Set Se- The left of gure 11.2 shows training time dependent on the size of the working set
lection q for the smallest Ohsumed task. The selection strategy from section 11.3 (lower
curve) is compared to a basic strategy similar to that proposed in Osuna et al.
(1996) (upper curve). In each iteration the basic strategy simply replaces half of
the working set with variables that do not fulll the optimality conditions. The
graph shows that the new selection strategy reduces time by a factor of more than
3.
11.7.3 What is the In
uence of Caching?
Caching The curves in the graph on the right hand side of gure 11.2 shows that caching
has a strong impact on training time. The lower curve shows training time (for an
RBF-kernel with = 10 and C = 50 on the 9337 examples of the Ohsumed data)
dependent on the cache size when shrinking is used. With the cache size ranging
from 2 megabytes to 80 megabytes a speedup factor of 2.8 is achieved. The speedup
generally increases with an increasing density of the feature vectors xi .
11.8 Conclusions
This chaper presents an improved algorithm for training SVMs on large-scale prob-
lems and describes its ecient implementation in SV M light . The algorithm is based
on a decomposition strategy and addresses the problem of selecting the variables
for the working set in an eective and ecient way. Furthermore, a technique for
\shrinking" the problem during the optimization process is introduced. This is
found particularly eective for large learning tasks where the fraction of SVs is
small compared to the sample size, or when many SVs are at the upper bound. The
chapter also describes how this algorithm is eciently implemented in SV M light .
It has a memory requirement linear in the number of training examples and in the
number of SVs. Nevertheless, the algorithms can benet from additional storage
space, since the caching strategy allows an elegant trade-o between training time
and memory consumption.
11.9 Acknowledgements
This work was supported by the DFG Collaborative Research Center on Complexity
Reduction in Multivariate Data (SFB475). Thanks to Alex Smola for letting me
use his solver. Thanks also to Shumeet Baluja and to John Platt for the data sets.
11.11 Notation
We conclude with a list of symbols which are used throughout the book, unless
stated otherwise.
R the set of reals
N the set of natural numbers
k Mercer kernel
F feature space
N dimensionality of input space
xi input patterns
yi target values, or (in pattern recognition) classes
` number of training examples
w weight vector
b constant oset (or threshold)
h VC-dimension
" parameter of the "-insensitive loss function
i Lagrange multiplier
vector of all Lagrange multipliers
i slack variables
Q Hessian of the quadratic program
(x y) dot product between patterns x and yp
k:k 2-norm (Euclidean distance), kxk := (x x)
ln logarithm to base e
log2 logarithm to base 2
Decision function:
X̀ !
f (x) = sgn yi i (x xi ) + b (11.41)
i=1