I'm trying to plot decision boundaries of SVM
with different kernels like rbf
, poly
, and linear
.
I am using iris
data set available online which is in shape of 150 * 4, so I had dropped the 4th feature and now it's in shape of 150 * 3 . Notice that each class now contains 50 samples with 3 features in order of their appearances.
class1 = iris[:50, :], class2 = iris[50:100, :], class3 = iris[100:150, :]
I have already plotted the one with 'linear' kernel BUT I have no idea about how to plot with other kernels. I've searched for days and didn't found anything that I would understand or I could use.
These are two surfaces which separates different classes
z_linear = lambda x, y: (-clf.intercept_[0] - clf.coef_[0][0] * x - clf.coef_[0][1] * y) / clf.coef_[0][2]
w_linear = lambda x, y: (-clf.intercept_[2] - clf.coef_[2][0] * x - clf.coef_[2][1] * y) / clf.coef_[2][2]
Now I need to plot 3 classes and the surfaces that separates them by using other kernels (i.e 'rbf', 'poly' with 'degree=3')