0

I'm using Support Vector Machine in a project. The library chosen is SVM light of Joachims: http://svmlight.joachims.org/

I have the need to calculate the margin. Namely, given a training set of data I have to calculate the margin of the better hyperplane found. But I do not see a direct way to do this in svm light. So I'll ask you to know how to do it. The data should be linearly separable and in this case I expect a positive margin, but there is also the remote possibility that in some case the data arent't linearly separable and in this case I expect a negative margin. (I use hard margin) Is there a possibility to do that in this library?

Umbert
  • 133
  • 7

1 Answers1

1

For the linearly separable case (using linear kernel), there is a script on SVM Light site's FAQ that can give you the weight vector (w) from the svm_model output file, http://www.cs.cornell.edu/people/tj/svm%5Flight/svm_light_faq.html (look for the question "How can I get the weight vector of the hyperplane for a linear SVM?").

With the weight vector you can calculate the margin by doing one over its norm: $\frac{1}{\lVert w \rVert}$

hygorxaraujo
  • 111
  • 3
  • 2
    In case the link goes dead at some point in future, this page version is actually [available on archive.org](https://web.archive.org/web/20170917044231/http://www.cs.cornell.edu/people/tj/svm_light/svm_light_faq.html) – Silverfish Apr 17 '18 at 16:55