Support Vector Machine (SVM) Algorithm - GeeksforGeeks
Support Vector Machine (SVM) Algorithm - GeeksforGeeks
The best hyperplane, also known as the “hard margin,” is the one
that maximizes the distance between the hyperplane and the
nearest data points from both classes. This ensures a clear
separation between the classes. So, from the above figure, we
choose L2 as hard margin.
Here, we have one blue ball in the boundary of the red ball.
It’s simple! The blue ball in the boundary of red ones is an outlier
of blue balls. The SVM algorithm has the characteristics to ignore
the outlier and finds the best hyperplane that maximizes the
margin. SVM is robust to outliers.
The penalty used for violations is often hinge loss, which has the
following behavior:
If a data point is correctly classified and within the margin, there
is no penalty (loss = 0).
If a point is incorrectly classified or violates the margin, the
hinge loss increases proportionally to the distance of the
violation.
Data Science IBM Certification Data Science Data Science Projects Data Analysis Data Visualiza
wT x + b = 0
Where:
w is the normal vector to the hyperplane (the direction
perpendicular to it).
b is the offset or bias term, representing the distance of the
hyperplane from the origin along the normal vector w.
The distance between a data point x_i and the decision boundary
can be calculated as:
w T xi +b
di =
∣∣w∣∣
minimize 12 ∥w∥2
w,b
yi (w T xi + b) ≥ 1 f or i = 1, 2, 3, ⋯ , m
Where:
yi is the class label (+1 or -1) for each training instance.
minimize 12 ∥w∥2 + C ∑m
i=1 ζi
w,b
yi (w T xi + b) ≥ 1–ζi
and ζi ≥ 0 for i = 1, 2, … , m
Where:
maximize 12 ∑m m
m
i=1 ∑j=1 αi αj ti tj K (xi , xj )– ∑i=1 αi
Where:
sample.
ti is the class label for the iii-th training sample (+1+1+1 or −1-
1−1).
K(xi , xj ) is the kernel function that computes the similarity
Where w is the weight vector, x is the test data point, and b is the
bias term.
ti (w T xi –b) = 1
⇒ b = w T xi –ti
# Scatter plot
plt.scatter(X[:, 0], X[:, 1],
c=y,
s=20, edgecolors="k")
plt.show()
Output:
Breast Cancer Classifications with SVM RBF kernel
Similar Reads
Major Kernel Functions in Support Vector Machine (SVM)
In previous article we have discussed about SVM(Support Vector
Machine) in Machine Learning. Now we are going to learn in detail…
4 min read
9 min read
Support Vector Machine (SVM) for Anomaly Detection
Support Vector Machines (SVMs) are powerful supervised learning
models that can also be used for anomaly detection. They can be…
8 min read
10 min read
6 min read
6 min read
6 min read
7 min read
5 min read
Registered Address:
K 061, Tower K, Gulshan Vivante
Apartment, Sector 137, Noida, Gautam
Buddh Nagar, Uttar Pradesh, 201305
Advertise with us
Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Privacy Policy GfG Weekly Contest
Careers Offline Classes (Delhi/NCR)
In Media DSA in JAVA/C++
Contact Us Master System Design
GfG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL DSA Interview Questions
R Language Competitive Programming
Android Tutorial
DSA/Placements Development/Testing
DSA - Self Paced Course JavaScript Full Course
DSA in JavaScript - Self Paced Course React JS Course
DSA in Python - Self Paced React Native Course
C Programming Course Online - Learn C with Data Django Web Development Course
Structures Complete Bootstrap Course
Complete Interview Preparation Full Stack Development - [LIVE]
Master Competitive Programming JAVA Backend Development - [LIVE]
Core CS Subject for Interview Preparation Complete Software Testing Course [LIVE]
Mastering System Design: LLD to HLD Android Mastery with Kotlin [LIVE]
Tech Interview 101 - From DSA to System Design [LIVE]
DSA to Development [HYBRID]
Placement Preparation Crash Course [LIVE]