'Drawing svm linear graph

So I'm trying to create a graph to display my svm data. I'm trying to create a linear line to separate the attributes. I followed the method on the internet, and the line formed already has the right slope, but is in the wrong position.

This is my training data, I have checked the svm function and there is nothing wrong with it, even the test result shows 96% accuracy:

enter image description here

This is my lined training data:

enter image description here

it looks like the line has the right slope, but has the wrong position. I draw the line with the following code:

ax=plt.gca()
xlim=ax.get_xlim()
w = clf.coef_[0]

a = -w[0] / w[1]
xx = np.linspace(0,27.5)
yy = a * xx - clf.intercept_[0] / w[1]
plt.plot(xx,yy)
plt.scatter(X_test[:,0],X_test[:,1],c=y_test, cmap='winter')
plt.show()

Why is my line position wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source