\documentclass[11pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{epsfig}
\usepackage[tight]{subfigure}
\usepackage{algorithmic}
\usepackage{algorithm}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {#1} \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[5]{\handout{#1}{#2}{#3}{#4}{#5}}

\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{assumption}[theorem]{Assumption}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
\topmargin 0pt
\advance \topmargin by -\headheight
\advance \topmargin by -\headsep
\textheight 8.9in
\oddsidemargin 0pt
\evensidemargin \oddsidemargin
\marginparwidth 0.5in
\textwidth 6.5in

\parindent 0in
\parskip 1.5ex
%\renewcommand{\baselinestretch}{1.25}

\begin{document}

\lecture{Statistical Techniques in Robotics (16-831, F09)}{Lecture \#14 (Thursday October 8th)}{Lecturer: Drew Bagnell}{Scribe: Alan Kraut}{Support Vector Machines, part 2}

\section{SVM Review}

We have a set of linear constraints, that a binary classifier give the right classification on all training data. The linear classifier uses sign$(w^T f_i)$, where $w$ is a weight vector, and $f_i$ is a particular feature vector. The desired output class is $y_i \in [-1,1]$.
 
\begin{itemize}
\item These constraints can be expressed as
    \begin{equation}
    y_i w^T f_i \geq 0
    \end{equation}
    
\item This series of constraints has several problems. With any real data it will have either infinite or zero solutions. We also can't incrementally update it.
\item To find a single solution if there are infinite, we find the $w$ that allows the greatest possible margin. That is, we want to minimize $||w||^2$ subject to
    \begin{equation}
    y_i w^T f_i \geq 1
    \end{equation}

\item To allow us to find a solution with inconsistent constraints, we introduce a flex variable, $\xi$. We now want to minimize $\lambda ||w||^2 + \displaystyle\sum_i \xi_i$ subject to
    \begin{equation}
    y_i w^T f_i \geq 1-\xi_i,\quad \xi_i \geq 0
    \end{equation}
    
\item To make this online, we observe that $\xi = \max (0,1-y_i w^T f_i)$. This allows us to generate the loss function
    \begin{equation}
    l_t = \lambda ||w||^2 + \max (0,1-y_t w^T f_t)
    \end{equation}
    
\item Our update for $w$ is now as follows.
    \begin{equation}
    w \leftarrow w - 2 \alpha_t \lambda w
    \end{equation}
And if the output for this time step was incorrect,
    \begin{equation}
    w \leftarrow w + \alpha_t y_t f_t
    \end{equation}

\end{itemize} 

\section{Implementing SVMs}
\subsection{Selecting $\alpha_t$}
\begin{itemize}
\item Stock algorithm would be to set $\alpha_t$ proportional to $\frac{1}{\sqrt{t}}$.
\item If we have $d$ elements, each with a maximum value of $|f|_{max}$, the maximum gradient, $G$, is $\sqrt{d|f|_{max}}$.
\item This is not as good as we could do.
\item Notice that $l_t$ is an extremely good convex function. It is a quadratic plus a convex function. In the same way all convex functions lie above a line (a subgradient) from every point, $l_t$ lies above a quadratic from every point.
\item Specifically, if it is always the case that
\begin{equation}
f(y) \geq f(x) + \frac{H}{2}(y-x)^2 + \nabla f_x^T(y-x)
\end{equation}
then $f(x)$ is said to be H-strongly convex.
\item In this case $l_t$ is $\lambda$-strongly convex.
\item If $\alpha_t=\frac{G}{Ht}$, then regret$\leq\frac{G^2}{H}(1+\log{t})$. $\log{t}$ is \emph{really} good, and this learning rate and algorithm is essentially the current best for this class of problem.

\end{itemize}

\subsection{SVMs with Multiple Classes}
We can represent problems with more than two classes by having a weight vector, $w_i$ for each class.
\begin{itemize}
\item When we get a classification of a particular example (for example, example $i$ is of class 1), we generate a set of constraints that can be expressed as either
\begin{eqnarray}
w_1^Tf_i &\geq& w_2^Tf_i+1 \nonumber \\
w_1^Tf_i &\geq& w_3^Tf_i+1 \\
w_1^Tf_i &\geq& w_4^Tf_i+1 \nonumber \\
&\ldots& \nonumber
\end{eqnarray}
or
\begin{equation}
w_1^Tf_i \geq \displaystyle{\mathop{\mbox{max}}_{c \neq i}} (w_c^Tf_i + 1)
\end{equation}

\item By the same argument as before
\begin{equation}
\xi = \max (0,\max (w_c^Tf + 1) - w_1^Tf)
\end{equation}

\item We want to update each $w$ by gradient descent on the partial of the cost with respect to that particular $w$.
\item Remember the cost is $l_t = \lambda ||w||^2+\xi$. We want the update step to be
\begin{equation}
w_c \leftarrow w_c - \partial_{w_c}l_t
\end{equation}

\item In the case that the example was classified correctly, $\partial_{w_c} l_t = 0$. If it was misclassified, there are three cases with different partials: the correct class, the class we incorrectly decided this was an example of, and all others.
\begin{eqnarray}
\partial_{w_c} &=& -f_i, \quad y_i = c \\
\partial_{w_c} &=& f_i, \quad c = \displaystyle{\mathop{\mbox{argmax}}_{c}}(w_c^Tf_i + 1) \\
\partial_{w_c} &=& 0, \quad \text{otherwise}
\end{eqnarray}

\item That update is for the $\max$ representation. If we use the multiple constraints representation it is similar, except we update both $w_1$ and $w_c$ for all $c$ which violate the constraint.
\end{itemize}


\end{document}
