Home Support Vector Machine(SVM)
Post
Cancel

Support Vector Machine(SVM)

What is SVM?

Like Support Vector for Regression (SVR), there is a straight line called the Maximum Margin between two categories. The Maximum Margin Hyperplane is drawn equidistant from the two nearest points in each category. The two nearest points are called Support Vectors.
As you can see in the image below, a straight line parallel to the Maximum Margin Hyperplane and passing through the support vectors becomes a hyperplane. The hyperplane supports the decision boundary which is called Maximum Margin.


Thus, new data is classified according to whether it is in the negative or positive hyperplane.

Example



Code



1
2
3
4
5
6
7
8
9
10
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

classifier = SVC(kernel='linear') # you can change kernel if you want other model
classifier.fit(X_train, y_train)

y_pred = classifier.predict(X_test)



Result







Implementation

This post is licensed under CC BY 4.0 by the author.