Tutorial on Support Vector Machine
Loc Nguyen
Sunflower Soft Company, Ho Chi Minh City, Vietnam
Email address:
To cite this article:
Loc Nguyen. Tutorial on Support Vector Machine. Applied and Computational Mathematics. Special Issue: Some Novel Algorithms for Global Optimization and Relevant Subjects. Vol. 6, No. 4-1, 2017, pp. 1-15. doi: 10.11648/j.acm.s.2017060401.11
Received: September 7, 2015; Accepted: September 8, 2015; Published: June 17, 2016
Abstract: Support vector machine is a powerful machine learning method in data classification. Using it for applied researches is easy but comprehending it for further development requires a lot of efforts. This report is a tutorial on support vector machine with full of mathematical proofs and example, which help researchers to understand it by the fastest way from theory to practice. The report focuses on theory of optimization which is the base of support vector machine.
Keywords: Support Vector Machine, Optimization, Separating Hyperplane, Sequential Minimal Optimization
1. Support Vector Machine
Support vector machine (SVM) [1] is a supervised learning algorithm for classification and regression. Given a set of p-dimensional vectors in vector space, SVM finds the separating hyperplane that splits vector space into sub-set of vectors; each separated sub-set (so-called data set) is assigned by one class. There is the condition for this separating hyperplane: "it must maximize the margin between two sub-sets". Fig. 1 [2] shows separating hyperplanes H_{1}, H_{2}, and H_{3} in which only H_{2} gets maximum margin according to this condition.
Suppose we have some p-dimensional vectors; each of them belongs to one of two classes. We can find many p–1 dimensional hyperplanes that classify such vectors but there is only one hyperplane that maximizes the margin between two classes. In other words, the nearest between one side of this hyperplane and other side of this hyperplane is maximized. Such hyperplane is called maximum-margin hyperplane and it is considered as the SVM classifier.
Let {X_{1}, X_{2},…, X_{n}} be the training set of n vectors X_{i} (s) and let y_{i} = {+1, –1} be the class label of vector X_{i}. Each X_{i} is also called a data point with attention that vectors can be identified with data points and data point can be called point, in brief. It is necessary to determine the maximum-margin hyperplane that separates data points belonging to y_{i}=+1 from data points belonging to y_{i}=–1 as clear as possible.
According to theory of geometry, arbitrary hyperplane is represented as a set of points satisfying hyperplane equation specified by (1).
(1)
Where the sign "" denotes the dot product or scalar product and W is weight vector perpendicular to hyperplane and b is the bias. Vector W is also called perpendicular vector or normal vector and it is used to specify hyperplane. Suppose W=(w_{1}, w_{2},…, w_{p}) and X_{i}=(x_{i}_{1}, x_{i}_{2},…, x_{ip}), the scalar product is:
Given scalar value w, the multiplication of w and vector X_{i} denoted wX_{i} is a vector as follows:
Please distinguish scalar product and multiplication wX_{i}.
The essence of SVM method is to find out weight vector W and bias b so that the hyperplane equation specified by (1) expresses the maximum-margin hyperplane that maximizes the margin between two classes of training set.
The value b/|W| is the offset of the (maximum-margin) hyperplane from the origin along the weight vector W where |W| or ||W|| denotes length or module of vector W.
Note that we use two notations |.| and ||.|| for denoting the length of vector.
Additionally, the value 2/|W| is the width of the margin as seen in fig. 2. To determine the margin, two parallel hyperplanes are constructed, one on each side of the maximum-margin hyperplane. Such two parallel hyperplanes are represented by two hyperplane equations, as shown in (2) as follows.
(2)
Fig. 2 [2] illustrates maximum-margin hyperplane, weight vector W and two parallel hyperplanes. As seen in the fig. 2, the margin is limited by such two parallel hyperplanes. Exactly, there are two margins (each one for a parallel hyperplane) but it is convenient for referring both margins as the unified single margin as usual. You can imagine such margin as a road and SVM method aims to maximize the width of such road. Data points lying on (or are very near to) two parallel hyperplanes are called support vectors because they construct mainly the maximum-margin hyperplane in the middle. This is the reason that the classification method is called support vector machine (SVM).
To prevent vectors from falling into the margin, all vectors belonging to two classes y_{i}=1 and y_{i}=–1 have two following constraints, respectively:
As seen in fig. 2, vectors (data points) belonging to classes y_{i}=+1 and y_{i}=–1 are depicted as black circles and white circles, respectively. Such two constraints are unified into the so-called classification constraint specified by (3) as follows:
(3)
As known, y_{i}=+1 and y_{i}=–1 represent two classes of data points. It is easy to infer that maximum-margin hyperplane which is the result of SVM method is the classifier that aims to determined which class (+1 or –1) a given data point X belongs to. Your attention please, each data point X_{i} in training set was assigned by a class y_{i} before and maximum-margin hyperplane constructed from the training set is used to classify any different data point X.
Because maximum-margin hyperplane is defined by weight vector W, it is easy to recognize that the essence of constructing maximum-margin hyperplane is to solve the constrained optimization problem as follows:
Where |W| is the length of weight vector W and is the classification constraint specified by (3). The reason of minimizing is that distance between two parallel hyperplanes is 2/|W| and we need to maximize such distance in order to maximize the margin for maximum-margin hyperplane. Then maximizing 2/|W| is to minimize . Because it is complex to compute the length |W|, we substitute for when is equal to the scalar product as follows:
The constrained optimization problem is re-written, shown in (4) as below:
(4)
Where is called target function with regard to variable W. Function is called constraint function with regard to two variables W, b and it is derived from the classification constraint specified by (3). There are n constraints because training set {X_{1}, X_{2},…, X_{n}} has n data points X_{i} (s). Constraints inside (3) implicate the perfect separation in which there is no data point falling into the margin (between two parallel hyperplanes, see fig. 2). On the other hand, the imperfect separation allows some data points to fall into the margin, which means that each constraint function g_{i}(W,b) is subtracted by an error . The constraints become [3, p. 5]:
We have a n-component error vector ξ=(ξ_{1}, ξ_{2},…, ξ_{n}) for n constraints. The penalty is added to the target function in order to penalize data points falling into the margin. The penalty C is a pre-defined constant. Thus, the target function f(W) becomes:
If the positive penalty is infinity, then, target function f(W) may get maximal when all errors ξ_{i} must be 0, which leads to the perfect separation specified by (4).
Equation (5) specifies the general form of constrained optimization originated from (4).
(5)
Where C ≥ 0 is the penalty.
The Lagrangian function [4, p. 215] is constructed from constrained optimization problem specified by (5). Let L(W, b, ξ, λ, μ) be Lagrangian function where λ=(λ_{1}, λ_{2},…, λ_{n}) and μ=(μ_{1}, μ_{2},…, μ_{n}) are n-component vectors, λ_{i} ≥ 0 and μ_{i} ≥ 0, . We have:
In general, (6) represents Lagrangian function as follows:
(6)
Note that λ=(λ_{1}, λ_{2},…, λ_{n}) and μ=(μ_{1}, μ_{2},…, μ_{n}) are called Lagrange multipliers or Karush-Kuhn-Tucker multipliers [5] or dual variables. The sign "" denotes scalar product and every training data point X_{i} was assigned by a class y_{i} before.
Suppose (W^{*}, b^{*}) is solution of constrained optimization problem specified by (5) then, the pair (W^{*}, b^{*}) is minimum point of target function f(W) or target function f(W) gets minimum at (W^{*}, b^{*}) with all constraints . Note that W^{*} is called optimal weight vector and b^{*} is called optimal bias. It is easy to infer that the pair (W^{*}, b^{*}) represents the maximum-margin hyperplane and it is possible to identify (W^{*}, b^{*}) with the maximum-margin hyperplane. The ultimate goal of SVM method is to find out W^{*} and b^{*}. According to Lagrangian duality theorem [4, p. 216] [6, p. 8], the pair (W^{*}, b^{*}) is the extreme point of Lagrangian function as follows:
(7)
Where Lagrangian function L(W, b, ξ, λ, μ) is specified by (6).
Now it is necessary to solve the Lagrangian duality problem represented by (7) to find out W^{*}. Thus, the Lagrangian function L(W, b, ξ, λ, μ) is minimized with respect to the primal variables W, b and maximized with respect to the dual variables λ=(λ_{1}, λ_{2},…, λ_{n}) and μ=(μ_{1}, μ_{2},…, μ_{n}), in turn. If gradient of L(W, b, ξ, λ, μ) is equal to zero then, L(W, b, ξ, λ, μ) will gets minimum value with note that gradient of a multi-variable function is the vector whose components are first-order partial derivative of such function. Thus, setting the gradient of L(W, b, ξ, λ, μ) with respect to W, b, and ξ to zero, we have:
In general, W^{*} is determined by (8) as follows:
(8)
It is required to determine Lagrange multipliers λ=(λ_{1}, λ_{2},…, λ_{n}) in order to evaluate W^{*}. Substituting (8) into Lagrangian function L(W, b, ξ, λ, μ) specified by (6), we have:
(According to (8), L(W,b,ξ,λ,μ) gets minimum at and and )
Where l(λ) is called dual function represented by (9).
(9)
According to Lagrangian duality problem represented by (7), λ=(λ_{1}, λ_{2},…, λ_{n}) is calculated as the maximum point λ^{*}=(λ_{1}^{*}, λ_{2}^{*},…, λ_{n}^{*}) of dual function l(λ). In conclusion, maximizing l(λ) is the main task of SVM method because the optimal weight vector W^{*} is calculated based on the optimal point λ^{*} of dual function l(λ) according to (8).
Maximizing l(λ) is quadratic programming (QP) problem, specified by (10).
(10)
The constraints are implied from the equations when . The QP problem specified by (10) is also known as Wolfe problem [3, p. 42].
There are some methods to solve this QP problem but this report introduces a so-called Sequential Minimal Optimization (SMO) developed by author [7]. The SMO algorithm is very effective method to find out the optimal (maximum) point λ^{*} of dual function l(λ).
Moreover SMO algorithm also finds out the optimal bias b^{*}, which means that SVM classifier (W^{*}, b^{*}) is totally determined by SMO algorithm. The next section described SMO algorithm in detail.
2. Sequential Minimal Optimization
The ideology of SMO algorithm is to divide the whole QP problem into many smallest optimization problems. Each smallest problem relates to only two Lagrange multipliers. For solving each smallest optimization problem, SMO algorithm includes two nested loops as shown in table 1 [7, pp. 8-9]:
SMO algorithm solves each smallest optimization problem via two nested loops: |
1. The outer loop finds out the first Lagrange multiplier λi whose associated data point Xi violates KKT condition [5]. Violating KKT condition is known as the first choice heuristic. |
2. The inner loop finds out the second Lagrange multiplier λj according to the second choice heuristic. The second choice heuristic that maximizes optimization step will be described later. |
3. Two Lagrange multipliers λi and λj are optimized jointly according to QP problem specified by (10). |
SMO algorithm continues to solve another smallest optimization problem. SMO algorithm stops when there is convergence in which no data point violating KKT condition is found; consequently, all Lagrange multipliers λ1, λ2,…, λn are optimized. |
Before describing SMO algorithm in detailed, the KKT condition with subject to SVM is mentioned firstly because violating KKT condition is known as the first choice heuristic of SMO algorithm. KKT condition indicates both partial derivatives of Lagrangian function and complementary slackness are zero [5]. Referring (8) and (4), the KKT function of SVM is summarized as (11):
(11)
When we understand deeply convex optimization, the KKT condition is the same to the QP problem specified by (10) if target function and constraint sets are convex. Thus, the solution (W^{*}, λ^{*}) is saddle point of Lagrangian function.
KKT condition is analyzed into three following cases [3, p. 7]:
1. If λ_{i}=0 then, μ_{i} = C – λ_{i} = C. It implies ξ_{i}=0 from equation . Then, from equation we have:
2. If 0 < λ_{i} < C then, we have . Due to μ_{i} = C – λ_{i} > 0, it implies ξ_{i}=0 from equation . It is easy to infer that:
3. If λ_{i}=C then, we have μ_{i} = C – λ_{i} = 0 and . Due to μ_{i} = 0, it implies ξ_{i} ≥ 0 from equation . Given ξ_{i} ≥ 0 the equation leads to:
Let be prediction error, we have:
The KKT condition implies:
(12)
Equation (12) expresses directed corollaries from KKT condition. It is commented on (12) that if E_{i}=0, the KKT condition is always satisfied. Data points X_{i} satisfying equation y_{i}E_{i}=0 lie on the margin (lie on the two parallel hyperplanes). These points are called support vectors. According to KKT corollary, support vectors are always associated with non-zero Lagrange multipliers such that 0<λ_{i}<C. Note, such Lagrange multipliers 0<λ_{i}<C are also called non-boundary multipliers because they are not bounds such as 0 and C. So, support vectors are also known as non-boundary data points. It easy to infer from (8)
that support vectors along with their non-zero Lagrange multipliers form mainly the optimal weight vector W^{*} representing the maximum-margin hyperplane – the SVM classifier. This is the reason that this classification approach is called support vector machine (SVM). Fig. 3 [8, p. 5] illustrates an example of support vectors.
Violating KKT condition is the first choice heuristic of SMO algorithm. By negating three corollaries specified by (12), KKT condition is violated in three following cases:
By logic induction, these cases are reduced into two cases specified by (13).
(13)
Equation (13) is used to check whether given data point X_{i} violates KKT condition.
The main task of SMO algorithm (see table 1) is to optimize jointly two Lagrange multipliers in order to solve each smallest optimization problem, which maximizes the dual function l(λ).
Where,
Without loss of generality, two Lagrange multipliers λ_{i} and λ_{j} that will be optimized are λ_{1} and λ_{2} while all other multipliers λ_{3}, λ_{4},…, λ_{n} are fixed. Old values of λ_{1} and λ_{2} are denoted and . Your attention please, old values are known as current values. Thus, λ_{1} and λ_{2} are optimized based on the set: , , λ_{2}, λ_{3},…, λ_{n}. The old values and are initialized by zero [3, p. 9]. From the condition , we have:
and
It implies following equation of line with regard to two variables λ_{1} and λ_{2}:
(14)
Equation (14) specifies the linear constraint of two Lagrange multipliers λ_{1} and λ_{2}. This constraint is drawn as diagonal lines in fig. 4 [3, p. 9].
In fig. 4, the box is bounded by the interval [0, C] of Lagrange multipliers, . SMO algorithm moves λ_{1} and λ_{2} along diagonal lines so as to maximize the dual function l(λ). Multiplying two sides of equation
by y_{1}, we have:
Where s=y_{1}y_{2}. Let,
We have (15) as a variant of the linear constraint of two Lagrange multipliers λ_{1} and λ_{2} [3, p. 9]:
(15)
By fixing multipliers λ_{3}, λ_{4},…, λ_{n}, all arithmetic combinations of , , λ_{3}, λ_{4},…, λ_{n} are constants denoted by term "const". The dual function l(λ) is re-written [3, pp. 9-11]:
Let,
Let be the optimal weight vector based on old values of two aforementioned Lagrange multipliers. Following linear constraint of two Lagrange multipliers specified by (14), we have:
Let,
We have [3, p. 10]:
Let and assessing the coefficient of λ_{2}, we have [3, p. 11]:
(Where is the old value of the bias b)
According to (13), and are old prediction errors on X_{2} and X_{1}, respectively:
Recall that we had:
Thus, equation (16) specifies dual function with subject to the second Lagrange multiplier λ_{2} that is optimized in conjunction with the first one λ_{1} by SMO algorithm.
(16)
The first and second derivatives of dual function l(λ_{2}) with regard to λ_{2} are:
The quantity η is always non-negative due to:
Recall that the goal of QP problem is to maximize the dual function l(λ_{2}) so as to find out the optimal multiplier (maximum point) . The second derivative of l(λ_{2}) is always non-negative and so, l(λ_{2}) is concave function and there always exists the maximum point . The function l(λ_{2}) gets maximal if its first derivative is equal to zero:
Therefore, the new values of λ_{1} and λ_{2} that are solutions of the smallest optimization problem of SMO algorithm are:
Obviously, is totally determined in accordance with , thus we should focus on . Because multipliers λ_{i} are bounded, , it is required to find out the range of . Let L and U be lower bound and upper bound of , respectively. We have [3, pp. 11-13]:
1. If s = 1, then λ_{1} + λ_{2} = γ. There are two sub-cases (see fig. 5 [3, p. 12] ) as follows [3, p. 11]:
If γ ≥ C then L = γ – C and U = C.
If γ < C then L = 0 and U = γ.
2. If s = –1, then λ_{1} – λ_{2} = γ. There are two sub-cases (see fig. 6 [3, p. 13]) as follows [3, pp. 11-12]:
If γ ≥ 0 then L = 0 and U = C – γ.
If γ < 0 then L = –γ and U = C.
The value is clipped as follows [3, p. 12]:
In the case η=0 that is undetermined, is assigned by which bound (L or U) maximizes the dual function l(λ_{2}).
In general, table 2 summarizes how SMO algorithm optimizes jointly two Lagrange multipliers.
Basic tasks of SMO algorithm to optimize jointly two Lagrange multipliers are now described in detailed. The ultimate goal of SVM method is to determine the classifier (W^{*}, b^{*}). Thus, SMO algorithm updates optimal weight W^{*} and optimal bias b^{*} based on the new values and at each optimization step.
All multipliers λi (s), weight vector W, and bias b are initialized by zero. SMO algorithm divides the whole QP problem into many smallest optimization problems. Each smallest optimization problem focuses on optimizing two joint multipliers. SMO algorithm solves each smallest optimization problem via two nested loops: |
1. The outer loop alternates one sweep through all data points and as many sweeps as possible through non-boundary data points (support vectors) so as to find out the data point Xi that violates KKT condition according to (13). The Lagrange multiplier λi associated with such Xi is selected as the first multiplier aforementioned as λ1. Violating KKT condition is known as the first choice heuristic of SMO algorithm. |
2. The inner loop browses all data points at the first sweep and non-boundary ones at later sweeps so as to find out the data point X_{j} that maximizes the deviation where and are prediction errors on X_{i} and X_{j}, respectively, as seen in (16). The Lagrange multiplier λ_{j} associated with such X_{j} is selected as the second multiplier aforementioned as λ_{2}. Maximizing the deviation is known as the second choice heuristic of SMO algorithm. a. Two Lagrange multipliers λ_{1} and λ_{2} are optimized jointly, which results optimal multipliers and , as seen in table 2. b. SMO algorithm updates optimal weight W^{*} and optimal bias b^{*} based on the new values and according to (17). |
SMO algorithm continues to solve another smallest optimization problem. SMO algorithm stops when there is convergence in which no data point violating KKT condition is found. Consequently, all Lagrange multipliers λ1, λ2,…, λn are optimized and the optimal SVM classifier (W*, b*) is totally determined. |
Let be the new (optimal) weight vector, according (11) we have:
Let be the old weight vector:
It implies:
Let be the new prediction error on X_{2}:
The new (optimal) bias is determining by setting with reason that the optimal classifier (W^{*}, b^{*}) has zero error.
In general, equation (17) specifies the optimal classifier (W^{*}, b^{*}) resulted from each optimization step of SMO algorithm.
(17)
By extending the ideology shown in table 1, SMO algorithm is described particularly in table 3 [7, pp. 8-9] [3, p. 14].
When both optimal weight vector W^{*} and optimal bias b^{*} are determined by SMO algorithm or other methods, the maximum-margin hyperplane known as SVM classifier is totally determined. According to (1), the equation of maximum-margin hyperplane is expressed in (18) as follows:
(18)
For any data point X, classification rule derived from maximum-margin hyperplane (SVM classifier) is used to classify such data point X. Let R be the classification rule, equation (19) specifies the classification rule as the sign function of point X.
(19)
After evaluating R with regard to X, if R(X) =1 then, X belongs to class +1; otherwise, X belongs to class –1. This is the simple process of data classification.
The next section illustrates how to apply SMO into classifying data points where such data points are documents.
3. An Example of Data Classification by SVM
Given a set of classes C = {computer science, math}, a set of terms T = {computer, derivative} and the corpus = {doc1.txt, doc2.txt, doc3.txt, doc4.txt}. The training corpus (training data) is shown in following table 4 in which cell (i, j) indicates the number of times that term j (column j) occurs in document i (row i); in other words, each cell represents a term frequency and each row represents a document. There are four documents and each document belongs to only one class: computer science or math.
computer | derivative | class | |
doc1.txt | 20 | 55 | math |
doc2.txt | 20 | 20 | computer science |
doc3.txt | 15 | 30 | math |
doc4.txt | 35 | 10 | computer science |
Let X_{i} be data points representing documents doc1.txt, doc2.txt, doc3.txt, doc4.txt, doc5.txt. We have X_{1}=(20,55), X_{2}=(20,20), X_{3}=(15,30), and X_{4}=(35,10). Let y_{i}=+1 and y_{i}=–1 represent classes "math" and "computer science", respectively. Let x and y represent terms "computer" and "derivative", respectively and so, for example, it is interpreted that the data point X_{1}=(20,55) has abscissa x=20 and ordinate y=55. Therefore, term frequencies from table 4 is interpreted as SVM input training corpus shown in table 5.
x | y | yi | |
X1 | 20 | 55 | +1 |
X2 | 20 | 20 | –1 |
X3 | 15 | 30 | +1 |
X4 | 35 | 10 | –1 |
Data points X_{1}, X_{2}, X_{3}, and X_{4} are depicted in fig. 7 in which classes "math" (y_{i}=+1) and "computer" (y_{i}=–1) are represented by shading and hollow circles, respectively. Note that fig. 7 and fig. 8 in this report are drawn by the software Graph http://www.padowan.dk developed by author Ivan Johansen [9].
By applying SMO algorithm described in table 3 into training corpus shown in table 5, it is easy to calculate optimal multiplier λ^{*}, optimal weight vector W^{*} and optimal bias b^{*}. Firstly, all multipliers λ_{i} (s), weight vector W, and bias b are initialized by zero. This example focuses on perfect separation and so, .
At the first sweep:
The outer loop of SMO algorithm searches for a data point X_{i} that violates KKT condition according to (13) through all data points so as to select two multipliers that will be optimized jointly. We have:
Due to λ_{1}=0 < C=+∞ and y_{1}E_{1}=1*1=1 > 0, point X_{1} violates KKT condition according to (13). Then, λ_{1} is selected as the first multiplier. The inner loop finds out the data point X_{j} that maximizes the deviation . We have:
Because the deviation is maximal, the multiplier λ_{2} associated with X_{2} is selected as the second multiplier. Now λ_{1} and λ_{2} are optimized jointly according to table 2.
Optimal classifier (W^{*}, b^{*}) is updated according to (17).
Now we have:
The outer loop of SMO algorithm continues to search for another data point X_{i} that violates KKT condition according to (13) through all data points so as to select two other multipliers that will be optimized jointly. We have:
Due to λ_{3}=0 < C and y_{3}E_{3}=1*(10/7) > 0, point X_{3} violates KKT condition according to (13). Then, λ_{3} is selected as the first multiplier. The inner loop finds out the data point X_{j} that maximizes the deviation . We have:
Because both deviations and are maximal, the multiplier λ_{2} associated with X_{2} is selected randomly among {λ_{1}, λ_{2}} as the second multiplier. Now λ_{3} and λ_{2} are optimized jointly according to table 2.
(L and U are lower bound and upper bound of )
Optimal classifier (W^{*}, b^{*}) is updated according to (17).
Now we have:
The outer loop of SMO algorithm continues to search for another data point X_{i} that violates KKT condition according to (13) through all data points so as to select two other multipliers that will be optimized jointly. We have:
Due to λ_{4}=0 < C and y_{4}E_{4}=(–1)*(18/7) < 0, point X_{4} does not violate KKT condition according to (13). Then, the first sweep of outer loop stops with the results as follows:
Note that λ_{1} is approximated to 0 because it is very small.
At the second sweep:
The outer loop of SMO algorithm searches for a data point X_{i} that violates KKT condition according to (13) through non-boundary data points so as to select two multipliers that will be optimized jointly. Recall that non-boundary data points (support vectors) are ones whose associated multipliers are not bounds 0 and C (0<λ_{i}<C). At the second sweep, there are three non-boundary data points X_{1}, X_{2} and X_{3}. We have:
Due to and y_{1}E_{1} = 1*(–4) < 0, point X_{1} violates KKT condition according to (13). Then, λ_{1} is selected as the first multiplier. The inner loop finds out the data point X_{j} among non-boundary data points (0<λ_{i}<C) that maximizes the deviation . We have:
Because the deviation is maximal, the multiplier λ_{2} associated with X_{2} is selected as the second multiplier. Now λ_{1} and λ_{2} are optimized jointly according to table (2).
(L and U are lower bound and upper bound of )
Optimal classifier (W^{*}, b^{*}) is updated according to (17).
The second sweep stops with results as follows:
At the third sweep:
The outer loop of SMO algorithm searches for a data point X_{i} that violates KKT condition according to (13) through non-boundary data points so as to select two multipliers that will be optimized jointly. Recall that non-boundary data points (support vectors) are ones whose associated multipliers are not bounds 0 and C (0<λ_{i}<C). At the third sweep, there are only two non-boundary data points X_{2} and X_{3}. We have:
Due to and y_{3}E_{3} = 1*(4/7) > 0, point X_{3} violates KKT condition according to (13). Then, λ_{3} is selected as the first multiplier. Because there are only two non-boundary data points X_{2} and X_{3}, the second multiplier is λ_{2}. Now λ_{3} and λ_{2} are optimized jointly according to table (2).
(L and U are lower bound and upper bound of )
Optimal classifier (W^{*}, b^{*}) is updated according to (17).
The third sweep stops with results as follows:
After the third sweep, two non-boundary multipliers were optimized jointly. You can sweep more times to get more optimal results because data point X_{3} still violates KKT condition as follows:
Due to and y_{3}E_{3} = 1*(–32/35) < 0, point X_{3} violates KKT condition according to (13). But it takes a lot of sweeps so that SMO algorithm reaches absolute convergence (E_{3}=0 and hence, no KKT violation) because the penalty C is set to be +∞, which implicates the perfect separation. This is the reason that we can stop the SMO algorithm at the third sweep in this example. In general, you can totally stop the SMO algorithm after optimizing two last multipliers which implies that all multipliers were optimized.
As a result, W^{*} and b^{*} were determined:
The maximum-margin hyperplane (SVM classifier) is totally determined as below:
The SVM classifier is depicted in fig. 8.
Where the maximum-margin hyperplane is draw as bold line. Data points X_{2} and X_{3} are support vectors because their associated multipliers λ_{2} and λ_{3} are non-zero (0<λ_{2}=2/125<C=+∞, 0<λ_{3}=2/125<C=+∞). Your attention please, that weight vector W is depicted as an arrow indicates mainly its direction. The scale of weight vector
in fig. 8 is very small.
Derived from the above classifier , the classification rule is:
Now we apply classification rule
into document classification. Suppose the numbers of times that terms "computer" and "derivative" occur in document D are 40 and 10, respectively. We need to determine which class document D=(40, 10) is belongs to. We have:
Hence, it is easy to infer that document D belongs to class "computer science" (y_{i} = –1).
4. Conclusion
In general, the main ideology of SVM is to determine the separating hyperplane that maximizes the margin between two classes of training data. Based on theory of optimization, such optimal hyperplane is specified by the weight vector W^{*} and the bias b^{*} which are solutions of constrained optimization problem. It is proved that there always exist these solutions but the main issue of SVM is how to find out them when the constrained optimization problem is transformed into quadratic programming (QP) problem. SMO which is the most effective algorithm divides the whole QP problem into many smallest optimization problems. Each smallest optimization problem focuses on optimizing two joint multipliers. It is possible to state that SMO is the best implementation version of the "architecture" SVM.
SVM is extended by concept of kernel function. The dot product in separating hyperplane equation is the simplest kernel function. Kernel function is useful in case of requirement of data transformation [1, p. 21]. There are many pre-defined kernel functions available for SVM. Readers are recommended to research more about kernel functions [10].
References