Robust SVM
The robust SVM training problem can be expressed as a cone QP with second-order cone constraints:
The variables are , , , and . The matrix
System Message: WARNING/2 (X \in \mathbf{R}^{N×n})
latex exited with error
[stdout]
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(./math.tex
LaTeX2e <2018-12-01>
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amscls/amsthm.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/bm.sty) (./math.aux)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsb.fd)
! Package inputenc Error: Unicode character × (U+00D7)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.13 ...{12}{14}\selectfont $X \in \mathbf{R}^{N×
n}$
[1] (./math.aux) )
(see the transcript file for additional information)
Output written on math.dvi (1 page, 360 bytes).
Transcript written on math.log.
has as its
rows the training examples
and the vector
System Message: WARNING/2 (d \in
\{−1, 1\}^N)
latex exited with error
[stdout]
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(./math.tex
LaTeX2e <2018-12-01>
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amscls/amsthm.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/tools/bm.sty) (./math.aux)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsb.fd)
! Package inputenc Error: Unicode character − (U+2212)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.14 \{−
1, 1\}^N$
[1] (./math.aux) )
(see the transcript file for additional information)
Output written on math.dvi (1 page, 360 bytes).
Transcript written on math.log.
contains the training labels. The matrices
define the shape and the size of the uncertainty ellipsoids, and the matrix
is a selector matrix with zeros and one ‘1’ per
row.
means that the i’th training vector is
associated with the j’th uncertainty ellipsoid. For
, the
term
and the norm constraints are absent, and the problem
reduces to the standard linear SVM
Documentation
A custom solver for the robust SVM problem is available as a Python
module robsvm.py
. The module implements the following function:
-
robsvm
(X, labels, gamma, P, e)
Solves the ‘soft-margin’ robust SVM problem.
The first three input arguments are the data matrix
(with the training examples as rows),
the label vector , and the positive parameter
. The fourth input argument P must be a Python
list of matrices . The last
argument e is an -vector where the i’th element
is the index of the uncertainty
ellipsoid associated with the i’th training vector.
The function returns , , , ,
and the number of iterations (an integer).
Example
from robsvm import robsvm
from cvxopt import matrix, normal, uniform
# parameters
m, n = 60, 2
gamma = 10.0
# generate random problem data
X = 2.0*uniform(m,n)-1.0
d = matrix(1,(m,1))
# generate noisy labels
w0 = matrix([2.0,1.0])+normal(2,1); b0 = 0.4
z = 0.2*normal(m,1)
for i in range(m):
if (X[i,:]*w0)[0] + b0 < z[i]: d[i] = -1
# generate uncertainty ellipsoids
k = 2
P = [0.1*normal(4*n,n) for i in range(k)]
P = [ p.T*p for p in P]
e = matrix(0,(m,1))
for i in xrange(m):
if d[i] == -1: e[i] = 1
# solve SVM training problem
w, b, u, v, iterations = robsvm(X, d, gamma, P, e)