1
votes

I am unable to understand how decision boundary is calculated once we get the coefficients of the model.

Here is the link that I am referring: http://scikit-learn.org/stable/auto_examples/svm/plot_svm_margin.html

Here is the code

# get the separating hyperplane
w = clf.coef_[0]
a = -w[0] / w[1]
xx = np.linspace(-5, 5)
yy = a * xx - (clf.intercept_[0]) / w[1]

I didn't understand a = -w[0] / w[1] this line.

Why we are dividing one coefficient with another?

1
Also, can you please point me to the basic algebra involved in this calculation?vivek_ratnaparkhi

1 Answers

1
votes

The separating hyperplane has the form w[0]*x+w[1]*y+intercept=0. So

w[1]*y=-w[0]*x-intercept

Now divide both sides by w[1], and you get

y=-(w[0]/w[1])*x-intercept/w[1].

This is exactly the equation that appears in your code.