# Least-squares support vector machine

Least-squares support-vector machines (LS-SVM) for statistics and in statistical modeling, are least-squares versions of support-vector machines (SVM), which are a set of related supervised learning methods that analyze data and recognize patterns, and which are used for classification and regression analysis. In this version one finds the solution by solving a set of linear equations instead of a convex quadratic programming (QP) problem for classical SVMs. Least-squares SVM classifiers were proposed by Johan Suykens and Joos Vandewalle.[1] LS-SVMs are a class of kernel-based learning methods.

## From support-vector machine to least-squares support-vector machine

Given a training set ${\displaystyle \{x_{i},y_{i}\}_{i=1}^{N}}$ with input data ${\displaystyle x_{i}\in \mathbb {R} ^{n}}$ and corresponding binary class labels ${\displaystyle y_{i}\in \{-1,+1\}}$, the SVM[2] classifier, according to Vapnik's original formulation, satisfies the following conditions:

${\displaystyle {\begin{cases}w^{T}\phi (x_{i})+b\geq 1,&{\text{if }}\quad y_{i}=+1,\\w^{T}\phi (x_{i})+b\leq -1,&{\text{if }}\quad y_{i}=-1,\end{cases}}}$

which is equivalent to

${\displaystyle y_{i}\left[{w^{T}\phi (x_{i})+b}\right]\geq 1,\quad i=1,\ldots ,N,}$

where ${\displaystyle \phi (x)}$ is the nonlinear map from original space to the high- or infinite-dimensional space.

### Inseparable data

In case such a separating hyperplane does not exist, we introduce so-called slack variables ${\displaystyle \xi _{i}}$ such that

${\displaystyle {\begin{cases}y_{i}\left[{w^{T}\phi (x_{i})+b}\right]\geq 1-\xi _{i},&i=1,\ldots ,N,\\\xi _{i}\geq 0,&i=1,\ldots ,N.\end{cases}}}$

According to the structural risk minimization principle, the risk bound is minimized by the following minimization problem:

${\displaystyle \min J_{1}(w,\xi )={\frac {1}{2}}w^{T}w+c\sum \limits _{i=1}^{N}\xi _{i},}$
${\displaystyle {\text{Subject to }}{\begin{cases}y_{i}\left[{w^{T}\phi (x_{i})+b}\right]\geq 1-\xi _{i},&i=1,\ldots ,N,\\\xi _{i}\geq 0,&i=1,\ldots ,N,\end{cases}}}$

To solve this problem, we could construct the Lagrangian function:

${\displaystyle L_{1}(w,b,\xi ,\alpha ,\beta )={\frac {1}{2}}w^{T}w+c\sum \limits _{i=1}^{N}{\xi _{i}}-\sum \limits _{i=1}^{N}\alpha _{i}\left\{y_{i}\left[{w^{T}\phi (x_{i})+b}\right]-1+\xi _{i}\right\}-\sum \limits _{i=1}^{N}\beta _{i}\xi _{i},}$

where ${\displaystyle \alpha _{i}\geq 0,\ \beta _{i}\geq 0\ (i=1,\ldots ,N)}$ are the Lagrangian multipliers. The optimal point will be in the saddle point of the Lagrangian function, and then we obtain

${\displaystyle {\begin{cases}{\frac {\partial L_{1}}{\partial w}}=0\quad \to \quad w=\sum \limits _{i=1}^{N}\alpha _{i}y_{i}\phi (x_{i}),\\{\frac {\partial L_{1}}{\partial b}}=0\quad \to \quad \sum \limits _{i=1}^{N}\alpha _{i}y_{i}=0,\\{\frac {\partial L_{1}}{\partial \xi _{i}}}=0\quad \to \quad \alpha _{i}+\beta _{i}=c,\;i=1,\ldots ,N\quad \to \quad 0\leq \alpha _{i}\leq c,\;i=1,\ldots ,N.\end{cases}}}$

(1)

By substituting ${\displaystyle w}$ by its expression in the Lagrangian formed from the appropriate objective and constraints, we will get the following quadratic programming problem:

${\displaystyle \max Q_{1}(\alpha )=-{\frac {1}{2}}\sum \limits _{i,j=1}^{N}{\alpha _{i}\alpha _{j}y_{i}y_{j}K(x_{i},x_{j})}+\sum \limits _{i=1}^{N}\alpha _{i},}$

where ${\displaystyle K(x_{i},x_{j})=\left\langle \phi (x_{i}),\phi (x_{j})\right\rangle }$ is called the kernel function. Solving this QP problem subject to constraints in (1), we will get the hyperplane in the high-dimensional space and hence the classifier in the original space.

### Least-squares SVM formulation

The least-squares version of the SVM classifier is obtained by reformulating the minimization problem as

${\displaystyle \min J_{2}(w,b,e)={\frac {\mu }{2}}w^{T}w+{\frac {\zeta }{2}}\sum \limits _{i=1}^{N}e_{i}^{2},}$

subject to the equality constraints

${\displaystyle y_{i}\left[{w^{T}\phi (x_{i})+b}\right]=1-e_{i},\quad i=1,\ldots ,N.}$

The least-squares SVM (LS-SVM) classifier formulation above implicitly corresponds to a regression interpretation with binary targets ${\displaystyle y_{i}=\pm 1}$.

Using ${\displaystyle y_{i}^{2}=1}$, we have

${\displaystyle \sum \limits _{i=1}^{N}e_{i}^{2}=\sum \limits _{i=1}^{N}(y_{i}e_{i})^{2}=\sum \limits _{i=1}^{N}e_{i}^{2}=\sum \limits _{i=1}^{N}\left(y_{i}-(w^{T}\phi (x_{i})+b)\right)^{2},}$

with ${\displaystyle e_{i}=y_{i}-(w^{T}\phi (x_{i})+b).}$ Notice, that this error would also make sense for least-squares data fitting, so that the same end results holds for the regression case.

Hence the LS-SVM classifier formulation is equivalent to

${\displaystyle J_{2}(w,b,e)=\mu E_{W}+\zeta E_{D}}$

with ${\displaystyle E_{W}={\frac {1}{2}}w^{T}w}$ and ${\displaystyle E_{D}={\frac {1}{2}}\sum \limits _{i=1}^{N}e_{i}^{2}={\frac {1}{2}}\sum \limits _{i=1}^{N}\left(y_{i}-(w^{T}\phi (x_{i})+b)\right)^{2}.}$

Both ${\displaystyle \mu }$ and ${\displaystyle \zeta }$ should be considered as hyperparameters to tune the amount of regularization versus the sum squared error. The solution does only depend on the ratio ${\displaystyle \gamma =\zeta /\mu }$, therefore the original formulation uses only ${\displaystyle \gamma }$ as tuning parameter. We use both ${\displaystyle \mu }$ and ${\displaystyle \zeta }$ as parameters in order to provide a Bayesian interpretation to LS-SVM.

The solution of LS-SVM regressor will be obtained after we construct the Lagrangian function:

${\displaystyle {\begin{cases}L_{2}(w,b,e,\alpha )\;=J_{2}(w,e)-\sum \limits _{i=1}^{N}\alpha _{i}\left\{{\left[{w^{T}\phi (x_{i})+b}\right]+e_{i}-y_{i}}\right\},\\\quad \quad \quad \quad \quad \;={\frac {1}{2}}w^{T}w+{\frac {\gamma }{2}}\sum \limits _{i=1}^{N}e_{i}^{2}-\sum \limits _{i=1}^{N}\alpha _{i}\left\{\left[w^{T}\phi (x_{i})+b\right]+e_{i}-y_{i}\right\},\end{cases}}}$

where ${\displaystyle \alpha _{i}\in \mathbb {R} }$ are the Lagrange multipliers. The conditions for optimality are

${\displaystyle {\begin{cases}{\frac {\partial L_{2}}{\partial w}}=0\quad \to \quad w=\sum \limits _{i=1}^{N}\alpha _{i}\phi (x_{i}),\\{\frac {\partial L_{2}}{\partial b}}=0\quad \to \quad \sum \limits _{i=1}^{N}\alpha _{i}=0,\\{\frac {\partial L_{2}}{\partial e_{i}}}=0\quad \to \quad \alpha _{i}=\gamma e_{i},\;i=1,\ldots ,N,\\{\frac {\partial L_{2}}{\partial \alpha _{i}}}=0\quad \to \quad y_{i}=w^{T}\phi (x_{i})+b+e_{i},\,i=1,\ldots ,N.\end{cases}}}$

Elimination of ${\displaystyle w}$ and ${\displaystyle e}$ will yield a linear system instead of a quadratic programming problem:

${\displaystyle \left[{\begin{matrix}0&1_{N}^{T}\\1_{N}&\Omega +\gamma ^{-1}I_{N}\end{matrix}}\right]\left[{\begin{matrix}b\\\alpha \end{matrix}}\right]=\left[{\begin{matrix}0\\Y\end{matrix}}\right],}$

with ${\displaystyle Y=[y_{1},\ldots ,y_{N}]^{T}}$, ${\displaystyle 1_{N}=[1,\ldots ,1]^{T}}$ and ${\displaystyle \alpha =[\alpha _{1},\ldots ,\alpha _{N}]^{T}}$. Here, ${\displaystyle I_{N}}$ is an ${\displaystyle N\times N}$ identity matrix, and ${\displaystyle \Omega \in \mathbb {R} ^{N\times N}}$ is the kernel matrix defined by ${\displaystyle \Omega _{ij}=\phi (x_{i})^{T}\phi (x_{j})=K(x_{i},x_{j})}$.

### Kernel function K

For the kernel function K(•, •) one typically has the following choices:

• Linear kernel : ${\displaystyle K(x,x_{i})=x_{i}^{T}x,}$
• Polynomial kernel of degree ${\displaystyle d}$: ${\displaystyle K(x,x_{i})=\left({1+x_{i}^{T}x/c}\right)^{d},}$
• Radial basis function RBF kernel : ${\displaystyle K(x,x_{i})=\exp \left({-\left\|{x-x_{i}}\right\|^{2}/\sigma ^{2}}\right),}$
• MLP kernel : ${\displaystyle K(x,x_{i})=\tanh \left({k\,x_{i}^{T}x+\theta }\right),}$

where ${\displaystyle d}$, ${\displaystyle c}$, ${\displaystyle \sigma }$, ${\displaystyle k}$ and ${\displaystyle \theta }$ are constants. Notice that the Mercer condition holds for all ${\displaystyle c,\sigma \in \mathbb {R} ^{+}}$ and ${\displaystyle d\in N}$ values in the polynomial and RBF case, but not for all possible choices of ${\displaystyle k}$ and ${\displaystyle \theta }$ in the MLP case. The scale parameters ${\displaystyle c}$, ${\displaystyle \sigma }$ and ${\displaystyle k}$ determine the scaling of the inputs in the polynomial, RBF and MLP kernel function. This scaling is related to the bandwidth of the kernel in statistics, where it is shown that the bandwidth is an important parameter of the generalization behavior of a kernel method.

## Bayesian interpretation for LS-SVM

A Bayesian interpretation of the SVM has been proposed by Smola et al. They showed that the use of different kernels in SVM can be regarded as defining different prior probability distributions on the functional space, as ${\displaystyle P[f]\propto \exp \left({-\beta \left\|{{\hat {P}}f}\right\|^{2}}\right)}$. Here ${\displaystyle \beta >0}$ is a constant and ${\displaystyle {\hat {P}}}$ is the regularization operator corresponding to the selected kernel.

A general Bayesian evidence framework was developed by MacKay,[3][4][5] and MacKay has used it to the problem of regression, forward neural network and classification network. Provided data set ${\displaystyle D}$, a model ${\displaystyle \mathbb {M} }$ with parameter vector ${\displaystyle w}$ and a so-called hyperparameter or regularization parameter ${\displaystyle \lambda }$, Bayesian inference is constructed with 3 levels of inference:

• In level 1, for a given value of ${\displaystyle \lambda }$, the first level of inference infers the posterior distribution of ${\displaystyle w}$ by Bayesian rule
${\displaystyle p(w|D,\lambda ,\mathbb {M} )\propto p(D|w,\mathbb {M} )p(w|\lambda ,\mathbb {M} ).}$
• The second level of inference determines the value of ${\displaystyle \lambda }$, by maximizing
${\displaystyle p(\lambda |D,\mathbb {M} )\propto p(D|\lambda ,\mathbb {M} )p(\lambda |\mathbb {M} ).}$
• The third level of inference in the evidence framework ranks different models by examining their posterior probabilities
${\displaystyle p(\mathbb {M} |D)\propto p(D|\mathbb {M} )p(\mathbb {M} ).}$

We can see that Bayesian evidence framework is a unified theory for learning the model and model selection. Kwok used the Bayesian evidence framework to interpret the formulation of SVM and model selection. And he also applied Bayesian evidence framework to support vector regression.

Now, given the data points ${\displaystyle \{x_{i},y_{i}\}_{i=1}^{N}}$ and the hyperparameters ${\displaystyle \mu }$ and ${\displaystyle \zeta }$ of the model ${\displaystyle \mathbb {M} }$, the model parameters ${\displaystyle w}$ and ${\displaystyle b}$ are estimated by maximizing the posterior ${\displaystyle p(w,b|D,\log \mu ,\log \zeta ,\mathbb {M} )}$. Applying Bayes’ rule, we obtain

${\displaystyle p(w,b|D,\log \mu ,\log \zeta ,\mathbb {M} )={\frac {p(D|w,b,\log \mu ,\log \zeta ,\mathbb {M} )p(w,b|\log \mu ,\log \zeta ,\mathbb {M} )}{p(D|\log \mu ,\log \zeta ,\mathbb {M} )}},}$

where ${\displaystyle p(D|\log \mu ,\log \zeta ,\mathbb {M} )}$ is a normalizing constant such the integral over all possible ${\displaystyle w}$ and ${\displaystyle b}$ is equal to 1. We assume ${\displaystyle w}$ and ${\displaystyle b}$ are independent of the hyperparameter ${\displaystyle \zeta }$, and are conditional independent, i.e., we assume

${\displaystyle p(w,b|\log \mu ,\log \zeta ,\mathbb {M} )=p(w|\log \mu ,\mathbb {M} )p(b|\log \sigma _{b},\mathbb {M} ).}$

When ${\displaystyle \sigma _{b}\to \infty }$, the distribution of ${\displaystyle b}$ will approximate a uniform distribution. Furthermore, we assume ${\displaystyle w}$ and ${\displaystyle b}$ are Gaussian distribution, so we obtain the a priori distribution of ${\displaystyle w}$ and ${\displaystyle b}$ with ${\displaystyle \sigma _{b}\to \infty }$ to be

${\displaystyle {\begin{array}{l}p(w,b|\log \mu ,)=\left({\frac {\mu }{2\pi }}\right)^{\frac {n_{f}}{2}}\exp \left({-{\frac {\mu }{2}}w^{T}w}\right){\frac {1}{\sqrt {2\pi \sigma _{b}}}}\exp \left({-{\frac {b^{2}}{2\sigma _{b}}}}\right)\\\quad \quad \quad \quad \quad \quad \quad \propto \left({\frac {\mu }{2\pi }}\right)^{\frac {n_{f}}{2}}\exp \left({-{\frac {\mu }{2}}w^{T}w}\right)\end{array}}.}$

Here ${\displaystyle n_{f}}$ is the dimensionality of the feature space, same as the dimensionality of ${\displaystyle w}$.

The probability of ${\displaystyle p(D|w,b,\log \mu ,\log \zeta ,\mathbb {M} )}$ is assumed to depend only on ${\displaystyle w,b,\zeta }$ and ${\displaystyle \mathbb {M} }$. We assume that the data points are independently identically distributed (i.i.d.), so that:

${\displaystyle p(D|w,b,\log \zeta ,\mathbb {M} )=\prod \limits _{i=1}^{N}{p(x_{i},y_{i}|w,b,\log \zeta ,\mathbb {M} )}.}$

In order to obtain the least square cost function, it is assumed that the probability of a data point is proportional to:

${\displaystyle p(x_{i},y_{i}|w,b,\log \zeta ,\mathbb {M} )\propto p(e_{i}|w,b,\log \zeta ,\mathbb {M} ).}$

A Gaussian distribution is taken for the errors ${\displaystyle e_{i}=y_{i}-(w^{T}\phi (x_{i})+b)}$ as:

${\displaystyle p(e_{i}|w,b,\log \zeta ,\mathbb {M} )={\sqrt {\frac {\zeta }{2\pi }}}\exp \left({-{\frac {\zeta e_{i}^{2}}{2}}}\right).}$

It is assumed that the ${\displaystyle w}$ and ${\displaystyle b}$ are determined in such a way that the class centers ${\displaystyle {\hat {m}}_{-}}$ and ${\displaystyle {\hat {m}}_{+}}$ are mapped onto the target -1 and +1, respectively. The projections ${\displaystyle w^{T}\phi (x)+b}$ of the class elements ${\displaystyle \phi (x)}$ follow a multivariate Gaussian distribution, which have variance ${\displaystyle 1/\zeta }$.

Combining the preceding expressions, and neglecting all constants, Bayes’ rule becomes

${\displaystyle p(w,b|D,\log \mu ,\log \zeta ,\mathbb {M} )\propto \exp(-{\frac {\mu }{2}}w^{T}w-{\frac {\zeta }{2}}\sum \limits _{i=1}^{N}{e_{i}^{2}})=\exp(-J_{2}(w,b)).}$

The maximum posterior density estimates ${\displaystyle w_{MP}}$ and ${\displaystyle b_{MP}}$ are then obtained by minimizing the negative logarithm of (26), so we arrive (10).

## References

1. ^ Suykens, J. A. K.; Vandewalle, J. (1999) "Least squares support vector machine classifiers", Neural Processing Letters, 9 (3), 293–300.
2. ^ Vapnik, V. The nature of statistical learning theory. Springer-Verlag, New York, 1995.
3. ^ MacKay, D. J. C. Bayesian Interpolation. Neural Computation, 4(3): 415–447, May 1992.
4. ^ MacKay, D. J. C. A practical Bayesian framework for backpropagation networks. Neural Computation, 4(3): 448–472, May 1992.
5. ^ MacKay, D. J. C. The evidence framework applied to classification networks. Neural Computation, 4(5): 720–736, Sep. 1992.

## Bibliography

• J. A. K. Suykens, T. Van Gestel, J. De Brabanter, B. De Moor, J. Vandewalle, Least Squares Support Vector Machines, World Scientific Pub. Co., Singapore, 2002. ISBN 981-238-151-1
• Suykens J. A. K., Vandewalle J., Least squares support vector machine classifiers, Neural Processing Letters, vol. 9, no. 3, Jun. 1999, pp. 293–300.
• Vladimir Vapnik. The Nature of Statistical Learning Theory. Springer-Verlag, 1995. ISBN 0-387-98780-0
• MacKay, D. J. C., Probable networks and plausible predictions—A review of practical Bayesian methods for supervised neural networks. Network: Computation in Neural Systems, vol. 6, 1995, pp. 469–505.