Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm working through Stanford's computer vision course to refresh some of my math skills (http://vision.stanford.edu/teaching/cs223b/syllabus.html), and I've run into a problem while working with a simple 2d Support Vector Machine.

Basically, the SVM library I am using only returns the vector 'w', which is the normal to the hyperplane (or line in 2d). I have verified that I am getting the correct value. The problem is, it does not contain 'b' in the equation:

w.x + b = 0

How do I compute 'b', so that when I draw the line it correctly bisects my data?

Also, I've noticed that the library I'm using (liblinear for those interested) assumes that the hyperplane bisects the origin (again, it doesn't use 'b'). I believe it assumes that the data is centered about the origin? My question is, can I simply take the average position (avg) and translate all of my data points by avg? Is there a preferred method to prep the data before running it through a SVM?

share|improve this question
2  
Are you sure your library doesn't return the displacement? Although easy to calculate in principle, you need to be able to apply the kernel, so the library probably does supply $b$. Also, in some cases the data isn't separable and then you need to know the "penalty factor" to be able to calculate $b$. –  Yuval Filmus Jan 26 '11 at 6:35
    
Thanks. I will try looking at some other libraries and see if they return the displacement. –  user6261 Jan 26 '11 at 15:48
    
Are you doing classification or regression? I believe that you can recover $b$ from the KKT conditions. There are several good sights which cover the techniques. en.wikipedia.org/wiki/Support_vector_machine –  Tpofofn Mar 27 '11 at 16:45
    
Scikits.learn, which is a Python layer over LIBSVM, does return the bias parameter within SVM objects. It's easy to use; I would consider it. –  prpl.mnky.dshwshr Mar 22 '12 at 2:58

1 Answer 1

You should provide bias parameter for your problem. The bias parameter (B) leads to augmenting training samples $(x_i)$ to $(x_i, B)$, so the hyperplane vector will be $(w, b)$ instead $(w)$. For more details see section 2 of LIBLINEAR paper.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.