

\subsection{Questions on SVM with hard-margin}
\begin{questions}
    \question What is the decision boundary and the margin if we run a Hard-Margin SVM on the following set of points?\\\\
    \begin{figure}[H]
    \centering
    \includegraphics[scale=0.6]{fig/SVM.png}
    \end{figure}
    
    \begin{soln}
    Decision Boundary: x = 1.5, Margin = 1
    \end{soln}
    
    \question A few additional data points are added to the data set in Figures 3 (a) and 3 (b). Draw the new decision boundaries and give the margins corresponding to this boundaries.\newline
    In which case does the decision boundary undergo a change and why? 
    \begin{figure}[H]
    \centering
    \begin{minipage}{.45\linewidth}
        \centering
        \includegraphics[width=\linewidth]{fig/SVM(a).png}
        Figure 3(a)
    \end{minipage}\hfill
    \begin{minipage}{.45\linewidth}
        \centering
        \includegraphics[width=\linewidth]{fig/SVM(b).png}
        Figure 3(b)
    \end{minipage}\hfill
    \end{figure}
    
    \begin{soln}
    For figure 3(a) the decision boundary remains unchanged because the support vector is the same. 3(b) there is a non-vertical decision boundary. 
    \end{soln}
    
\end{questions}

\newpage

\subsection{Soft-margin linear SVM}
Given the following dataset in 1-d space (Figure 5), which consists of 4 positive data points and 3 negative data points. Suppose that we want to learn a soft-margin linear SVM for this data set. Remember that the soft-margin linear SVM can be formalized as the following constrained quadratic optimization problem. In this formulation, $C$ is the regularization parameter, which balances the size of margin (i.e., smaller $w^Tw$) vs. the violation of the margin (i.e. smaller $\sum_{i=1}^m \epsilon_i$).
\begin{figure}[H]
\centering
\includegraphics[scale=0.6]{fig/svm-soft.png}
\caption*{Figure 5}
\end{figure}
    
\begin{questions}
    \question If $C = \infty$, which means that we only care the violation of the margin, how many support vectors do we have?
    
    \begin{soln}
    2
    \end{soln}
    
    \question If $C = 0$, which means that we only care about the size of the margin, how many support vectors do we have?
    
    \begin{soln}
    7
    \end{soln}
    
\end{questions}
\newpage

\subsection{Margin trivia}

SVMs try to find the linear separator that maximises the \emph{margin} between datapoints.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.5\linewidth]{fig/svm_0.png}
    \caption{SVM decision boundary for some sample data}
\end{figure}

\begin{questions}
    
    \question How can we show that $w$ is perpendicular to the decision boundary of SVMs?
    
    \begin{soln}
    \begin{center}
        \includegraphics[width=0.5\linewidth]{fig/svm_1_ans.jpg}
    \end{center}
    Let us take two points $x_1$ and $x_2$ on the decision boundary of the SVM. So we know that both these points will satisfy the equation $w^Tx_1 + b = 0$ and $w^Tx_2 + b = 0$.
    
    Subtracting the two equations we get:
    \begin{align}
        w^Tx_1 + b - (w^Tx_2 + b) = 0 \\
        w^T (x_1 - x_2) = 0
    \end{align}
    Now we know that $x_1 - x_2$ is a vector along the decision boundary and as its dot product with $w$ is $0$, we can conclude they are perpendicular.
    \end{soln}

\end{questions}