-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path14_svm_2.tex
executable file
·419 lines (319 loc) · 13.3 KB
/
14_svm_2.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
\section{Support Vector Machines II}
\subsection{Hard Margin Problem}
\begin{frame}
\frametitle{Hard Margin Problem}
The hard margin SVM optimization problem is formulated as:
\begin{eqnarray*}
& \mbox{minimize} & \frac{1}{2} {\|\vec \alpha\|^2_2} \\[.3cm]
& \mbox{subject to} & \forall i: \quad y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) -1 \geq 0
\end{eqnarray*}
\end{frame}
\subsection{Soft Margin Problem}
\begin{frame}
\frametitle{Soft Margin Problem}
The soft margin SVM optimization problem is formulated as:
\begin{eqnarray*}
& \mbox{minimize} & \frac{1}{2} {\|\vec \alpha\|^2_2} + \mu \sum_i \xi_i \\[.5cm]
& \mbox{subject to} & \forall i: \quad -(y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) -1+\xi_i) \leq 0~, \\[.3cm]
& & \forall i: \quad -\xi_i \leq 0
\end{eqnarray*}
\end{frame}
\subsection{Lagrangian}
\begin{frame}
\frametitle{Lagrangian}
The solution of the \structure{constrained convex optimization problem} \\
requires the Lagrangian:
\begin{eqnarray*}
L(\vec \alpha, \alpha_0, \vec \xi, \vec \lambda, \vec \mu)
& = & \frac{1}{2} {\|\vec \alpha\|^2_2} + \mu \sum_i \xi_i -\sum_i \mu_i \xi_i\\
& & \quad - \sum_i \lambda_i (y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) -1+\xi_i)
\end{eqnarray*}
\end{frame}
\subsection{Lagrangian}
\begin{frame}
\frametitle{Lagrangian}
The solution of the \structure{constrained convex optimization problem} \\
requires the Lagrangian:
~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\bf{meta-}~~~~~~~~\bf{Lagrangian}\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\bf{parameter}~~~~\bf{multiplier}
\begin{eqnarray*}
L(\vec \alpha, \alpha_0, \vec \xi, \vec \lambda, \vec \mu)
& = & \frac{1}{2} {\|\vec \alpha\|^2_2} + {\color{red} \mu} \sum_i \xi_i -\sum_i {\color{red} \mu_i} \xi_i\\
& & \quad - \sum_i \lambda_i (y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) -1+\xi_i)
\end{eqnarray*}
\end{frame}
\subsection{Lagrangian}
\begin{frame}
\frametitle{Lagrangian}
The solution of the \structure{constrained convex optimization problem} \\
requires the Lagrangian:
~\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\bf{meta-}~~~~~~~~\bf{Lagrangian}\\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\bf{parameter}~~~~\bf{multiplier}
\begin{eqnarray*}
L(\vec \alpha, \alpha_0, \vec \xi, \vec \lambda, \vec \mu)
& = & \frac{1}{2} {\|\vec \alpha\|^2_2} + {\color{red} c} \sum_i \xi_i -\sum_i {\color{red} \mu_i} \xi_i\\
& & \quad - \sum_i \lambda_i (y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) -1+\xi_i)
\end{eqnarray*}
\end{frame}
\begin{frame}
\frametitle{Lagrangian \cont}
\structure{Partial derivatives I:}
\begin{displaymath}
\frac{\partial L(\vec \alpha, \alpha_0, \vec \xi, \vec \lambda, \vec \mu)}{\partial \vec \alpha} ~=~
\vec \alpha - \sum_i \lambda_i y_i \vec x_i ~\stackrel{!}{=}~
\vec 0.
\end{displaymath}
Thus we have:
\begin{displaymath}
\vec \alpha = \sum_i \lambda_i y_i \vec x_i~.
\end{displaymath}
\end{frame}
\begin{frame}
\frametitle{Lagrangian \cont}
\structure{Partial derivatives II:}
\begin{displaymath}
\frac{\partial L(\vec \alpha, \alpha_0, \vec \xi, \vec \lambda, \vec \mu)}{\partial \alpha_0} ~=~
-\sum_i \lambda_i y_i ~\stackrel{!}{=}~
0
\end{displaymath}
\pspread
\structure{Partial derivatives III:}
\begin{displaymath}
\frac{\partial L(\vec \alpha, \alpha_0, \vec \xi, \vec \lambda, \vec \mu)}{\partial \xi_i} ~=~
c - \mu_i - \lambda_i ~\stackrel{!}{=}~
0
\end{displaymath}
\end{frame}
\subsection{Lagrange Dual}
\begin{frame}
\frametitle{Lagrange Dual}
Let us consider the \structure{Lagrange function for the dual problem} for the hard margin case:
\begin{eqnarray*}
L_\text{D}
&=& \frac{1}{2} {\vec \alpha^T \vec \alpha} -
\sum_i \lambda_i (y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) -1) \\[.3cm] \pause
&=& \frac{1}{2}{\vec \alpha^T \vec \alpha} -
(\underbrace{\sum_i \lambda_i y_i\cdot \vec x_i)^T}_{{\vec \alpha^T}} \vec \alpha -
\underbrace{ \sum_i \lambda_iy_i}_{ = 0}\ \alpha_0 +
\sum_i \lambda_i \\[.3cm] \pause
&=& -\frac{1}{2} \sum_i \sum_j \lambda_i \lambda_j y_i y_j \cdot \vec x_i^T\vec x_j + \sum_i \lambda_i
\end{eqnarray*}
\end{frame}
\begin{frame}
\frametitle{The Lagrange Dual Problem}
The Lagrange dual problem is given by the optimization problem: \\[.25cm]
\begin{center}
\tikz[baseline]{
\node[fill=bl1!100,anchor=base,rounded corners=3pt] (d1) {
\color{bl3}
$\begin{aligned}
\displaystyle
\mbox{maximize} & \qquad -\frac{1}{2} \sum_i \sum_j \lambda_i \lambda_j y_i y_j \cdot \vec x_i^T\vec x_j + \sum_i \lambda_i \\[.3cm]
\mbox{subject to} & \qquad \vec{\lambda}\succeq 0 \\
& \qquad \sum_{i} \lambda_i \, y_i = 0
\end{aligned}$
};
}
\end{center}
\pause
\structure{Benefits of the dual representation}
\begin{itemize}
\item The model can be reformulated using kernels.
\item SVMs can be applied efficiently to feature spaces whose dimensionality exceeds the number of samples.
\end{itemize}
\end{frame}
\note{
From Bishop: Pattern Recognition and Machine Learning
The solution to a quadratic programming problem in $d$ variables in general has computational complexity that is $\mathcal{O}(d^3)$.
In going to the dual formulation we have turned the original optimization problem, which involved minimizing
\begin{eqnarray*}
& \mbox{minimize} & \frac{1}{2} {\|\vec \alpha\|^2_2} \\[.3cm]
& \mbox{subject to} & \forall i: \quad y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) -1 \geq 0
\end{eqnarray*}
over $d$ variables, into the dual problem, which has $m$ variables.
For a fixed set of basis functions whose number $d$ is smaller than the number $m$ of data points, the move to the dual problem appears disadvantageous.
However, it allows the model to be reformulated using kernels, and so the maximum margin classifier can be applied efficiently to feature spaces whose dimensionality exceeds the number of data points, including infinite feature spaces.
The kernel formulation also makes clear the role of the constraint that the kernel function $k(\vec{x},\vec{x}')$ be positive definite, because this ensures that the Lagrangian function $L_\text{D}$ is bounded below, giving rise to a well-defined optimization problem.
}
\begin{frame}
\frametitle{Lagrange Dual Problem \cont}
For convex optimization problems with differentiable objective and constraint functions, the duality gap is zero,
if the KKT conditions are satisfied. \\[.5cm] \pause
Especially the \structure{complementary slackness} condition is interesting for us:
\begin{displaymath}
\forall i: \quad \lambda_i \, f_i(\vec{x}) = 0
\end{displaymath}
\end{frame}
\begin{frame}
\frametitle{Lagrange Dual Problem \cont}
\structure{Complementary slackness for hard margin SVMs:}
\begin{displaymath}
\forall i: \quad \lambda_i \, (y_i\cdot (\vec \alpha^T\vec x_i + \alpha_0) - 1) = 0 \pause
\end{displaymath}
\structure{Implications:} \\[.2cm]
\begin{enumerate}
\item If $\lambda_i>0$, then $y_i \, (\vec{\alpha}^T \vec{x}_i + \alpha_0) - 1=0$, and thus:
\begin{displaymath}
y_i(\vec{\alpha}^T \vec{x}_i + \alpha_0) = 1~.
\end{displaymath}
All $\vec x_i$ with $\lambda_i>0$ are elements at the boundary of the slab; \\
these samples are called \structure{\emph{support vectors}}. \\[.2cm] \pause
\item We have seen that $ \vec \alpha = \sum_i \lambda_i y_i \vec x_i $, thus the norm vector of the decision boundary is a linear combination of support vectors.
\end{enumerate}
\end{frame}
\begin{frame}
\frametitle{Dual Representation}
The \structure{decision function} can also be rewritten using the duality:
\begin{center}
\tikz[baseline]{
\node[fill=bl1!100,anchor=base,rounded corners=3pt] (d1) {
\color{bl3}
$\begin{aligned}
\displaystyle
f(\vec x) =
\vec{\alpha}^T \vec{x} +\alpha_0 =
\sum_{i=1}^m \lambda_i y_i \vec x_i^T \vec x + \alpha_0
\end{aligned}$
};
}
\end{center}
\pause
\vspace{.5cm}
\structure{Conclusion:} \\[.2cm]
Feature vectors only appear in inner products, both in the learning and the classification phase.
\end{frame}
\subsection{Feature Transforms}
\begin{frame}
\frametitle{Feature Transforms}
\structure{Linear decision boundaries} in its current form have serious \structure{limitations}: \\[.2cm]
\begin{itemize}
\item Non-linearly separable data cannot be classified. \\[.3cm]
\item Noisy data cause problems. \\[.3cm]
\item Formulation deals with vectorial data only.
\end{itemize}
\pspread
\structure{Possible solution:} \\[.2cm]
\begin{itemize}
\item Map data into richer feature space using non-linear feature transform, \\
then use a linear classifier.
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Feature Transforms \cont}
We select a feature transform
\begin{displaymath}
\phi: \real^d \rightarrow \real^D, \quad D \ge d
\end{displaymath}
such that the resulting features
\begin{displaymath}
\phi(\vec x_i), \quad i = 1, 2, \dots, m
\end{displaymath}
are linearly separable.
\end{frame}
\begin{frame}
\frametitle{Feature Transforms \cont}
\begin{ovalblock}{Example}
Assume the decision boundary is given by the quadratic function
\begin{displaymath}
f(\vec x) = a_0 + a_1 x_1^2 + a_2 x_2^2 + a_3 x_1 x_2 + a_4 x_1+a_5 x_2.
\end{displaymath}
Obviously this is not a linear decision boundary. \\[.25cm] \pause
By the following mapping, we get features that have a linear decision boundary:
\small
\begin{displaymath}
\phi(\vec x) = \left(\begin{array}{c}
1 \\ x_1^2 \\ x_2^2 \\ x_1x_2 \\ x_1 \\ x_2
\end{array}
\right)
\end{displaymath}
\end{ovalblock}
\end{frame}
\begin{frame}
\frametitle{Feature Transforms \cont}
These feature transforms can be easily incorporated into SVMs:\\[.25cm]
\begin{itemize}
\item \structure{Decision boundary:}
{\small
\begin{displaymath}
f(\vec x) = \sum_i \lambda_i y_i \cdot \langle\phi(\vec x_i), \phi(\vec x) \rangle + \alpha_0 \pause
\end{displaymath}
}
\item The Lagrange dual problem is given by the \structure{optimization problem}:
{\small
\begin{eqnarray*}
\mbox{maximize} & & -\frac{1}{2} \sum_i \sum_j \lambda_i \lambda_j y_i y_j \cdot \langle\phi(\vec x_i),\phi(\vec x_j)\rangle + \sum_i \lambda_i \\[.5cm]
\mbox{subject to} & &\vec{\lambda}\succeq 0, \quad \sum_{i} \lambda_i \, y_i = 0
\end{eqnarray*}
}
\end{itemize}
\end{frame}
\subsection{Kernel Functions}
\begin{frame}
\frametitle{Kernel Functions}
We now define \structure{kernel functions}:
\begin{displaymath}
k(\vec x, \vec x') = \langle \phi(\vec x), \phi(\vec x') \rangle
\end{displaymath}
\pspread
Typical kernel functions are: \\[.25cm]
\small
\begin{itemize}
\item \structure{Linear:}
\begin{displaymath}
k(\vec x, \vec x') =~ \langle\vec x, \vec x'\rangle
\end{displaymath}
\item \structure{Polynomial:}
\begin{displaymath}
k(\vec x, \vec x') = (\langle\vec x, \vec x'\rangle + 1)^k
\end{displaymath}
\item \structure{Radial basis function:}
\begin{displaymath}
k(\vec x, \vec x') = e^{-\gamma\|\vec x- \vec x'\|_2^2}
\end{displaymath}
\item \structure{Sigmoid kernel:}
\begin{displaymath}
k(\vec x, \vec x') =\mbox{tanh}({ \alpha \langle\vec x, \vec x'\rangle + \beta})
\end{displaymath}
\end{itemize}
\end{frame}
\subsection{Lessons Learned}
\begin{frame}
\frametitle{Lessons Learned}
\begin{itemize}
\item Lagrangian formulation of the hard and soft margin problems \\[.5cm]
\item Lagrange dual representation \\[.5cm]
\item Idea of feature transforms
\end{itemize}
\end{frame}
\input{nextTime.tex}
\subsection{Further Readings}
\begin{frame}
\frametitle{Further Readings}
\begin{itemize}
\item Bernhard Sch{\"o}lkopf, Alexander J. Smola: \\
\structure{Learning with Kernels}, \\
The MIT Press, Cambridge, 2003. \\[.15cm]
\item Vladimir N. Vapnik: \\
\structure{The Nature of Statistical Learning Theory}, \\
Information Science and Statistics, Springer, Heidelberg, 2000. \\[.15cm]
\item S.~Boyd, L.~Vandenberghe: \\
\structure{Convex Optimization}, \\
Cambridge University Press, 2004. \\
\point{\small \url{http://www.stanford.edu/~boyd/cvxbook/}} \\[.15cm]
\item Christopher M.\ Bishop: \\
\structure{Pattern Recognition and Machine Learning}, \\
Springer, New York, 2006
\end{itemize}
\end{frame}
\subsection{Comprehensive Questions}
\begin{frame}
\frametitle{Comprehensive Questions}
\begin{itemize}
\item What is the Lagrangian of the hard margin SVM? \\[1cm]
\item What are the KKT optimality conditions for the hard margin SVM? \\[1cm]
\item How do we apply the KKT conditions to the Lagrange Dual? \\[1cm]
\item What can we conclude from this reformulated Lagrange Dual?
\end{itemize}
\end{frame}