0% found this document useful (0 votes)
11 views4 pages

Experiment 6 - Minords

The document outlines an experiment for a Data Science using Python Lab course, focusing on implementing and evaluating the Support Vector Machine (SVM) algorithm. It explains the theory behind SVM, including its types (linear and non-linear), how it works, and its applications in classification problems. The aim is to enable students to apply SVM on datasets and validate the results using Python.

Uploaded by

Swapnil Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Experiment 6 - Minords

The document outlines an experiment for a Data Science using Python Lab course, focusing on implementing and evaluating the Support Vector Machine (SVM) algorithm. It explains the theory behind SVM, including its types (linear and non-linear), how it works, and its applications in classification problems. The aim is to enable students to apply SVM on datasets and validate the results using Python.

Uploaded by

Swapnil Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Academic Year: 2023-24 Semester: VI

Class / Branch: TE IT A/B Subject: DS using Python Lab

Experiment No. 6

Aim: To choose a classification problem and evaluate the performance using SVM algorithm.

Prerequisites: Python

Objectives: At the end of this experiment, you will be able to:

• To implement SVM using python


• Apply SVM on dataset and validate results

Theory:

Support Vector Machine Algorithm

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 chooses the extreme points/vectors that help in creating the hyperplane. These extreme
cases are called support vectors, and hence the algorithm is termed as Support Vector Machine.
Consider the below diagram in which there are two different categories that are classified using a
decision boundary or hyperplane:

Department of Information Technology | APSIT


Academic Year: 2023-24 Semester: VI
Class / Branch: TE IT A/B Subject: DS using Python Lab

SVM algorithm can be used for Face detection, image classification, text categorization, etc.

Types of SVM
SVM can be of two types:

o 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.
o 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.

How does SVM works?


Linear SVM:
The working of the SVM algorithm can be understood by using an example. Suppose we have a
dataset that has two tags (green and blue), and the dataset has two features x1 and x2. We want a
classifier that can classify the pair(x1, x2) of coordinates in either green or blue. Consider the
below image:

Department of Information Technology | APSIT


Academic Year: 2023-24 Semester: VI
Class / Branch: TE IT A/B Subject: DS using Python Lab

So as it is 2-d space so by just using a straight line, we can easily separate these two classes. But
there can be multiple lines that can separate these classes. Consider the below image:

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:

Department of Information Technology | APSIT


Academic Year: 2023-24 Semester: VI
Class / Branch: TE IT A/B Subject: DS using Python Lab

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.

So to separate these data points, we need to add one more dimension. For linear data, we have
used two dimensions x and y, so for non-linear data, we will add a third dimension z. It can be
calculated as:
z=x2 +y2

Conclusion: In this experiment, we have implemented SVM in python and visualized its results.

Department of Information Technology | APSIT

You might also like