SVM Manual
SVM Manual
PROGRAM 7: Apply and analyse Support Vector Machine algorithm with different kernel
functions and parameter values for a linearly separable and non-linearly separable
classification Task
AIM:
To Apply and analyse Support Vector Machine algorithm with different kernel functions and
parameter values for a linearly separable and non-linearly separable classification Task.
THEORY:
Support Vectors: These are the points that are closest to the hyperplane. A separating line will be
defined with the help of these data points.
Margin: it is the distance between the hyperplane and the observations closest to the hyperplane
(support vectors). In SVM large margin is considered a good margin. There are two types of margins
hard margin and soft margin.
Let’s understand the working of SVM using an example. Suppose we have a dataset that has two
classes (green and blue). We want to classify that the new data point as either blue or green.
To classify these points, we can have many decision boundaries, but the question is which is the
best and how do we find it? NOTE: Since we are plotting the data points in a 2-dimensional graph
we call this decision boundary a straight line but if we have more dimensions, we call this decision
boundary a “hyperplane”.
Here we see we cannot draw a single line or say hyperplane which can classify the points correctly.
So what we do is try converting this lower dimension space to a higher dimension space using some
quadratic functions which will allow us to find a decision boundary that clearly divides the data
points. These functions which help us do this are called Kernels and which kernel to use is purely
determined by hyperparameter tuning.
1. Polynomial Kernel
2. Sigmoid Kernel
3. RBF Kernel
Choosing a kernel totally depends on what kind of dataset are you working on. If it is linearly
separable then you must opt. for linear kernel function since it is very easy to use and the complexity
is much lower compared to other kernel functions.
You can then work your way up towards the more complex kernel functions. Usually, we use SVM
with RBF and linear kernel function because other kernels like polynomial kernel are rarely used
due to poor efficiency.
Advantages of SVM
Disadvantages of SVM
SAMPLE OUTPUT: