Arjun Sunil
Success - Implementing SVM on 10 Class Data Set With 256 Features
Story of how I succesfully implemented my first ML algorithm

So, I had exams recently and couldn’t work much on ML or any thing.. Out of the blue I get a notification on my phone. Boom. A bomb drops, Machine Learning assignment. So, I thought it might be the usual thing write some thing, copy it as usual, and submit. Thats what I thought.. Until I see the first two question..

All the happiness of practical exams getting over changes into despair.. Here were the questions

Write an R function to implement PCA. Download LIBSVM and train it on the USPS data set available at the Precision and Recall computed for each class in the USPS test data. Are you kidding bro? My course doesnt have R as a language, the first thing we were taught here was just plain old C. How do you expect us to write a function in R that too to implement PCA? Okay yes you taught us what is PCA but, alas its a lot of math.. I couldn’t understand that well enough 😐 So, thats two things, R and PCA that I don’t know..

Moving on..

Question 2:? No one knows how to do a binary classification.. Do you really think a baby could run already??? Well I see it as a challenge though..

I go ahead and download the data set to find 10 classes, 256 features… I’ve got no clue what should I be doing.. Nor do I know what to do.. I dont even know where to begin with; but thats not gonna stop me.

I head over to that link and go through the guide available.. Still trying to figure out what should I do for this thing 😐

An update, 3 days after struggling to understand the seemingly easy readme..

I decided to ask my senior for help with implementing svmlib on the given dataset.

All I had to do, was run the following commands in the svmlib folder:

$ make

This step makes executable files for svmlib

$ ./svm-train usps

Trains svmlib using the training set named usps and creates a usps.model file within pwd.

$ ./svm-predict usps.t usps.model OutputValue

Uses the usps.t(test file), the model we created in previous step and saves predictions to a file named OutputValue within the same directory.

and done!

Thats all I had to do to get predictions and I ran my first actual machine learning algorithm!!!

The above mentioned svm data set had 10 classes and 256 features. On paper it seems hard but honestly this was my first ever machine learning algorithm implementation..

I’m leaving a link to the repo I made for this Assignment

I got an accuracy of 93.7718%!!! I loved my first hands on experience with SVM.

Okay, I take back all the things I said about thinking that sir gave us a damn hard task for the classification.. It was actually damn easy and all I had to do was read with a clear mind..

If anyone has any doubts regarding libsvm and its implementation? Drop a comment down below. I’m no expert, but I will surely try to help you 🙂

Last modified on 2020-07-26

Comments powered by Disqus