Support Vector Machine
Support Vector Machine
SVM
Support Vector Machine or SVM is one of the most popular Supervised
Learning algorithms, which is used for Classification as well as Regression
problems.
However, primarily, it is used for Classification problems in Machine
Learning.
The goal of the SVM algorithm is to create the best line or decision
boundary that can segregate n-dimensional space into classes so that we
can easily put the new data point in the correct category in the future.
This best decision boundary is called a hyperplane.
SVM
SVM algorithm can be used for Face detection, image classification, text categorization, etc.
Types Of SVM
SVM can be of two types:
•Linear SVM: Linear SVM is used for linearly separable data, which means if a dataset can be classified into two
classes by using a single straight line, then such data is termed as linearly separable data, and classifier is used
called as Linear SVM classifier.
•Non-linear SVM: Non-Linear SVM is used for non-linearly separated data, which means if a dataset cannot be
classified by using a straight line, then such data is termed as non-linear data and classifier used is called as Non-
linear SVM classifier.
Hyperplane and Support Vectors in the SVM
algorithm:
Hyperplane: There can be multiple lines/decision boundaries to segregate the classes in n-dimensional space, but
we need to find out the best decision boundary that helps to classify the data points. This best boundary is known
as the hyperplane of SVM.
The dimensions of the hyperplane depend on the features present in the dataset, which means if there are 2
features (as shown in image), then hyperplane will be a straight line. And if there are 3 features, then hyperplane
will be a 2-dimension plane.
We always create a hyperplane that has a maximum margin, which means the maximum distance between the
data points.
Support Vectors:
The data points or vectors that are the closest to the hyperplane and which affect the position of the hyperplane are
termed as Support Vector. Since these vectors support the hyperplane, hence called a Support vector.
How does SVM works? Linear SVM
The working of the SVM So as it is 2-d space so by
algorithm can be understood by just using a straight line, we
using an example. Suppose we can easily separate these
have a dataset that has two tags two classes. But there can
(green and blue), and the dataset be multiple lines that can
has two features x1 and x2. We separate these classes.
want a classifier that can classify Consider the below image:
the pair(x1, x2) of coordinates in
either green or blue. Consider
the below image:
Optimal Hyperplane
Hence, the SVM algorithm helps to find the best line or decision boundary; this best boundary or region is called
as a hyperplane. SVM algorithm finds the closest point of the lines from both the classes. These points are called
support vectors. The distance between the vectors and the hyperplane is called as margin. And the goal of SVM
is to maximize this margin. The hyperplane with maximum margin is called the optimal hyperplane.
Non-linear SVM
If data is linearly arranged, then we can separate it by using a straight line, but for non-linear data, we cannot
draw a single straight line. Consider the below image:
In the SVM classifier, it is easy to have a linear hyper-plane between these two classes. But,
another burning question which arises is, should we need to add this feature manually to have a
hyper-plane. No, the SVM algorithm has a technique called the kernel trick
The SVM kernel is a function that takes low dimensional input space and transforms it to a higher
dimensional space i.e. it converts not separable problem to separable problem.
It is mostly useful in non-linear separation problem.
Simply put, it does some extremely complex data transformations, then finds out the process to
separate the data based on the labels or outputs you’ve defined.