SVM-1
SVM-1
Defini on: SVM is a popular supervised machine learning algorithm used for
classifica on and regression problems. However, it is typically used for classifica on.
Supervised Learning: SVM requires labelled data as input.
Classifica on Problems: These involve predic ng a target variable with a discrete
number of possibili es (e.g., spam or not spam).
Regression Problems: These involve predic ng a target variable with con nuous
values (e.g., salary increase).
How SVM Works for Classifica on
The primary goal of an SVM algorithm is to find the best decision boundary or
hyperplane that segregates the given dataset into mul ple classes.`
Once this hyperplane is established, new examples can be classified into one of the
classes based on which side of the hyperplane they fall on.
Hyperplane
The decision boundary in SVM is called a hyperplane.
The dimension of the hyperplane depends on the number of features in the dataset.
o For two features (X, Y), the hyperplane will be a straight line.
o For more than two features, the hyperplane will be a plane or a higher-
dimensional hyperplane.
The crucial aspect is to draw the hyperplane in a way that achieves the maximum
margin.
Finding the Best Hyperplane: Maximum Margin
There can be mul ple lines (in 2D) or hyperplanes that can separate the data.
The best hyperplane is the one that has the maximum margin.
To determine the maximum margin, we consider the nearest data points from each
class to the possible hyperplanes.
Support Vectors
The nearest data points to a par cular hyperplane are called support vectors.
These support vectors play a crucial role in defining and determining the op mal
hyperplane with the maximum margin.
Linear SVM
Defini on: A linear SVM is used when the data can be separated with a straight line
(in 2D) or a linear hyperplane (in higher dimensions).
In summary, SVM aims to find the op mal hyperplane that separates data into different
classes by maximizing the margin between the closest data points (support vectors) of each
class. Linear SVM works when the data is linearly separable, while Non-Linear SVM uses
mapping func ons to handle non-linearly separable data by projec ng it into a higher-
dimensional space.
Drawing a Hyperplane in Linear SVM: A Solved Example
This provides a step-by-step demonstra on of how to find and draw an op mal hyperplane
for a linearly separable dataset in SVM.
1. Understanding the Data Set
The example dataset consists of posi ve and nega ve examples in a 2D space.
Posi ve examples: (4, 1), (4, -1), (6, 0).
Nega ve examples: (1, 0), (0, 1), (0, -1).
The goal is to find a hyperplane (a line in 2D) that best separates these two classes.
This aligns with the general goal of SVM, which is to find the best decision boundary
to segregate data [Me].
o α₁ (S1̄ ⋅ S2̄) + α₂ (S2̄ ⋅ S2̄) + α₃ (S3̄ ⋅ S2̄) = +1 (since S2̄ is from the posi ve class)
o α₁ (S1̄ ⋅ S3̄) + α₂ (S2̄ ⋅ S3̄) + α₃ (S3̄ ⋅ S3̄) = +1 (since S3̄ is from the posi ve class)
5. Calcula ng Dot Products and Forming Simultaneous Equa ons
The dot products between the augmented support vectors are calculated:
o S1̄ ⋅ S1̄ = (1*1) + (0*0) + (1*1) = 2
o S2̄ ⋅ S1̄ = (4*1) + (1*0) + (1*1) = 5
o S3̄ ⋅ S1̄ = (4*1) + (-1*0) + (1*1) = 5
o S1̄ ⋅ S2̄ = (1*4) + (0*1) + (1*1) = 5
o S2̄ ⋅ S2̄ = (4*4) + (1*1) + (1*1) = 18
o S3̄ ⋅ S2̄ = (4*4) + (-1*1) + (1*1) = 16