0
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

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}$

$\endgroup$
  • 2
    $\begingroup$ In case the link goes dead at some point in future, this page version is actually available on archive.org $\endgroup$ – Silverfish Apr 17 '18 at 16:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.