1
votes

In the case of a binary classification for Support Vector Machines, each new point x' is classied by evaluating,

y' = sign(w . x' + b)

This is the case for the primal problem.

I wanted to find out the classifier equation, for which I need to find the "w" vector and the constant "b". I'm implementing it in Python using the scikit-learn package.

In scikit-learn package w vector can be found by the attribute "coef_", but how do I find the value of the constant b?

from sklearn import svm
cll = svm.SVC(kernel='linear')
cll.fit(X, Y) #X is the instances and Y is the output variable
w = cll.coef_[0]

How do I find b?

Note: "intercept_" attribute contains holds the independent term -P from the dual form, and not from the primal form.

1

1 Answers

3
votes

Note: "intercept_" attribute contains holds the independent term -P from the dual form, and not from the primal form.

There is no "independent term" in dual form (dual optimization formulation is unbiased). This is the b from y' = sign(w . x' + b), which is equivalent to y' = sign( SUM_i alpha_i K(sv_i, x) + b )