Friday, December 13, 2013

Exercise 7: SVM Linear Classification

Machine Learning:

'via Blog this'
Exercise 7: SVM Linear Classification
This exercise gives you practice with using SVMs for linear classification. You will use a free SVM software package called LIBSVM that interfaces to MATLAB/Octave. To begin, download the LIBSVM Matlab Interface (choose the package with the description "a simple MATLAB interface") and unzip the contents to any convenient location on your computer.
Then, download the data for this exercise: ex7Data.zip.

Installing LIBSVM
After you've downloaded the LIBSVM Matlab Interface, follow the instructions in the package's README file to build LIBSVM from its source code. Instructions are provided for both Matlab and Octave on Unix and Windows systems.
If you've built LIBSVM successfully, you should see 4 files with the suffix "mexglx" ("mexw32" on Windows). These are the binaries that you will run from MATLAB/Octave, and you need to make them visible to your working directory for this exercise. This can be done in any of the following 3 ways:
(1). Creating links to the binaries from your working directory
(2). Adding the location of the binaries to the Matlab/Octave path
(3). Copying the binaries to your working directory.
Linear classification
Recall from the video lectures that SVM classification solves the following optimization problem:

\begin{displaymath}
\min_{w,b}\qquad\left\Vert w\right\Vert ^{2}+C\sum_{i}^{m}\xi_{i}
\end{displaymath}

\begin{eqnarray*}
\mbox{subject to}\qquad y^{(i)}(w^{T}x^{(i)}+b) & \geq & 1-\xi_{i},\qquad i=1,2...,m\\
\xi_{i} & \geq & 0,\qquad i=1,2...,m\end{eqnarray*}


After solving, the SVM classifier predicts "1" if $w^T x + b \geq 0$ and "-1" otherwise. The decision boundary is given by the line $w^T x + b = 0$.

No comments:

Post a Comment