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?

  • 2
    $\begingroup$ 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$. $\endgroup$ – Yuval Filmus Jan 26 '11 at 6:35
  • $\begingroup$ Thanks. I will try looking at some other libraries and see if they return the displacement. $\endgroup$ – user6261 Jan 26 '11 at 15:48
  • $\begingroup$ 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 $\endgroup$ – Tpofofn Mar 27 '11 at 16:45
  • $\begingroup$ 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. $\endgroup$ – ely Mar 22 '12 at 2:58

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy