Standardize Features

Train Support Vector Classifier

Plot Decision Boundary Hyperplane

In this visualization, all observations of class 0 are black and observations of class 1 are light gray. The hyperplane is the decision-boundary deciding how new observations are classified. Specifically, any observation above the line will by classified as class 0 while any observation below the line will be classified as class 1.

# Plot data points and color using their classcolor=['black'ifc==0else'lightgrey'forciny]plt.scatter(X_std[:,0],X_std[:,1],c=color)# Create the hyperplanew=svc.coef_[0]a=-w[0]/w[1]xx=np.linspace(-2.5,2.5)yy=a*xx-(svc.intercept_[0])/w[1]# Plot the hyperplaneplt.plot(xx,yy)plt.axis("off"),plt.show();