0% found this document useful (0 votes)
9 views5 pages

B43 Exp3 ML

Uploaded by

Nikhil Aher
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)
9 views5 pages

B43 Exp3 ML

Uploaded by

Nikhil Aher
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/ 5

PART A

( PART A: TO BE REFERRED BY STUDENTS)

Experiment No. 03
A.1 Aim:
To implement a Support Vector Machine.

A.2 Prerequisite:
Python Basic Concepts

A.3 Outcome:
Students will be able To implement a Support Vector Machine. A.4

Theory:

Machine Learning, being a subset of Artificial Intelligence (AI), has been


playing a dominant role in our daily lives. Data science engineers and developers
working in various domains are widely using machine learning algorithms to make
their tasks simpler and life easier.

The objective of the support vector machine algorithm is to find a hyperplane


in an N-dimensional space(N — the number of features) that distinctly classifies the
data points. To separate the two classes of data points, there are many possible
hyperplanes that could be chosen. Our objective is to find a plane that has the maximum
margin, i.e the maximum distance between data points of both classes. Maximizing the
margin distance provides some reinforcement so that future data points can be classified
with more confidence. Hyperplanes are decision boundaries that help classify the data
points. Data points falling on either side of the hyperplane can be attributed to different
classes. Also, the dimension of the hyperplane depends upon the number of features. If
the number of input features is 2, then the hyperplane is just a line. If the number of
input features is 3, then the hyperplane becomes a two-dimensional plane. It becomes
difficult to imagine when the number of features exceeds
3.

Types of SVM

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.
SVM algorithm is implemented with kernel that transforms an input data space into
the required form. SVM uses a technique called the kernel trick in which kernel takes
a low dimensional input space and transforms it into a higher dimensional space. In
simple words, kernel converts non-separable problems into separable problems by adding
more dimensions to it. It makes SVM more powerful, flexible and accurate. The
following are some of the types of kernels used by SVM.

Linear Kernel

It can be used as a dot product between any two observations. The formula of
linear kernel is as below −

K(x,xi)=sum(x ∗ xi)K(x,xi)=sum(x ∗ xi)

From the above formula, we can see that the product between two vectors say
𝑥 & 𝑥𝑖 is the sum of the multiplication of each pair of input values.

Polynomial Kernel

It is more generalized form of linear kernel and distinguish curved or nonlinear


input space. Following is the formula for polynomial kernel − k(X,Xi)=1+sum(X ∗
Xi)^dk(X,Xi)=1+sum(X ∗ Xi)^d

Here d is the degree of polynomial, which we need to specify manually in the


learning algorithm.

Pros and Cons of SVM Classifiers

● SVM classifiers offers great accuracy and work well with high dimensional
space. SVM classifiers basically use a subset of training points hence in result
uses very less memory.
● They have high training time hence in practice not suitable for large datasets.
Another disadvantage is that SVM classifiers do not work well with overlapping
classes.

PART B
( PART B : TO BE COMPLETED BY STUDENTS)
Roll. No.: B43 Name: Nikhil Aher

Class: Fourth Year (B) Batch: B3

Date of Experiment: 26/07/24 Date of Submission: 31/07/24


Grade:
B.1 Software Code written by student:

B.2 Input and Output:


B.3 Observations and learning:
Implementing a Support Vector Machine (SVM) reveals several key observations
and learnings. SVMs are highly effective for classification tasks, particularly in high-
dimensional spaces, due to their ability to find the optimal hyperplane that maximizes
the margin between classes. The use of support vectors, which are the critical data
points influencing the hyperplane, ensures that the model is robust. Non-linear data can
be managed through kernel functions, which transform the feature space to enable linear
separation. Key parameters like the regularization parameter (C) significantly impact
model performance, with a high C potentially leading to overfitting and a low C risking
underfitting. While SVMs provide strong classification capabilities, they can be
computationally intensive and require careful parameter tuning to achieve the best results.
This underscores the importance of understanding the balance between margin
maximization and classification accuracy in practical applications. B.4 Conclusion:
Implementing a Support Vector Machine (SVM) involves finding the optimal
hyperplane that maximally separates classes in the feature space. SVMs use support
vectors—data points closest to the hyperplane—to define this boundary. For non-linear
problems, kernel functions (e.g., polynomial, RBF) transform the data into higher
dimensions to enable linear separation. Key parameters include the regularization
parameter (C), which balances margin size and classification error. While SVMs are
powerful and effective in high-dimensional spaces, they can be computationally intensive
and require careful parameter tuning to avoid overfitting or underfitting.

**********

You might also like