Support Vector Machine RBF | When Linear Kernels Fail, RBF Succeeds
Key Takeaways
Builds a Support Vector Machine with Radial Basis Function kernel using Scikit-learn to classify moon-shaped data
Full Transcript
[Music] Welcome to this video on using the radial basis function or in short RBF kernel to improve classification accuracy in support vector machines. Sometimes data isn't nicely separated by a straight line and that's where the RBF kernel comes in. We'll start by importing the necessary libraries. We need numpy for numerical operations, mapplot liib for visualization and several modules from scitle learn including the SVM implementation, data generation tools and evaluation metrics. To demonstrate the power of nonlinear SVMs, we are generating a nonlinearly separable data set using scikitlearn's make moons function. This creates two interle half moon shapes that can't be properly separated with a straight line. We're adding some noise to make the problem more realistic. Here we can see our data set visualized. Notice how the two classes form curved moonshaped patterns. If we tried to separate these points with a straight line, we'd always mclassify some of the data. This is exactly the type of problem where nonlinear SVMs shine. Now let's implement our SVM classifier with the RBF kernel. We're using scikitlearn's pipeline functionality to first standardize our data which is an important pre-processing step for SVMs. Then we are creating an SVC classifier with the RBF kernel. The gamma parameter is set to scale, which is a good default that adjusts based on our data's variance. To understand what's happening under the hood, we need to visualize the decision boundary created by our RBF kernel. We've defined a function that creates a fine mesh grid over our feature space and predicts the class for each point in this grid. This allows us to see exactly how our SVM is separating the data. This visualization reveals the power of the RBF kernel. Look at how the decision boundary curves to perfectly separate the two moon shapes. This nonlinear boundary would be impossible to achieve with a linear kernel which can only create straight line decision boundaries. For a proper evaluation, we are splitting our data into training and testing sets. We'll use 80% for training and 20% for testing, which will give us an unbiased assessment of our model's performance. The results demonstrate the effectiveness of the RBF kernel. We're achieving 96% accuracy on our test set, which confirms that our model is successfully capturing the nonlinear patterns in the data. This classification report provides additional metrics like precision, recall, and F1 score, all of which are perfect for both classes. For comparison, let's see how a linear kernel performs on the same data. We're creating another SVM classifier, but this time specifying a linear kernel. Everything else remains exactly the same, including the standardization processing. This sidebyside comparison clearly illustrates why nonlinear SBMs are so powerful for complex data sets. On the left, we see the RBF kernel creating a curved decision boundary that nicely separates our two classes. On the right, we see the linear kernel struggling with a straight line boundary that mclassifies many points. Notice how the linear kernels accuracy is significantly lower than the RBF kernels. This demonstrates how nonlinear kernels can dramatically improve classification accuracy when dealing with data that isn't linearly separable. All right. In this demonstration, we've seen how the RBF kernel transforms SVMs into powerful nonlinear classifiers. Thank you for following along. [Music]
Original Description
When straight lines fail, curves succeed! This *Support Vector Machine (SVM)* tutorial shows why *Radial Basis Function (RBF) kernels* achieve better accuracy on moon-shaped data where linear kernels struggle. Watch curved decision boundaries bend around complex patterns that straight lines can't handle.
This video is part of the *Machine Learning with Scikit-learn, PyTorch & Hugging Face Professional Certificate on Coursera.* Practice non-linear classification with RBF (Radial Basis Function) kernels. You'll discover:
*Why some data can't be separated by straight lines (moon-shaped patterns)
*RBF kernel implementation with Scikit-learn pipeline and standardization
*Gamma parameter tuning ('scale' setting for optimal performance)
*Decision boundary visualization revealing curved classification boundaries
*Accuracy achievement on complex non-linear dataset
*Direct comparison: RBF kernel vs Linear kernel performance
*Visual proof of RBF superiority for non-linearly separable data
*Real-world applications where curved boundaries outperform linear ones
📌 Enroll in the complete *Machine Learning with Scikit-learn, PyTorch & Hugging Face Professional Certificate →* https://bit.ly/4nuBB4l
✅ Subscribe for advanced SVM & kernel method tutorials → https://www.youtube.com/@coursera/
💬 Comment: What real-world problems have you seen that need curved decision boundaries? Medical diagnosis? Image recognition? 🤔
00:00 Introduction – RBF kernel for non-linear SVM classification
00:27 Library Setup – NumPy, Matplotlib, Sklearn tools
00:45 Dataset Generation – Moon-shaped non-linear patterns with noise
01:15 Data Visualization – Why straight lines can't separate moon shapes
01:41 RBF SVM Implementation – Pipeline with standardization and RBF kernel
02:04 Decision Boundary – Visualizing curved classification boundaries
02:46 RBF Power Demonstration – Perfect separation of moon patterns
03:14 Model Evaluation – Train/test split for unbiased assessment
03:33 Results Analysis – 96%
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Coursera · Coursera · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Principles of Obesity Economics with Professor Kevin Frick
Coursera
Introduction to the U.S. Food System: Perspectives from Public Health by John Hopkins University
Coursera
E-learning and Digital Cultures
Coursera
Equine Nutrition with Jo-Anne Murray
Coursera
Coursera Meetup BBQ
Coursera
Contraception: Choices, Culture and Consequences with Jerusalem Makonnen
Coursera
Nutrition for Health Promotion and Disease Prevention with Katie Clark
Coursera
Information Security and Risk Management in Context with Dr. Barbara Endicott-Popovsky
Coursera
Contraception: Choices, Culture and Consequences with Jerusalem Makonnen
Coursera
Writing in the Sciences with Kristin Sainani
Coursera
Economic Issues, Food, and You with Jennifer Clark
Coursera
Leading Strategic Innovation and Creativity in Organizations with David A. Owens, PhD
Coursera
Useful Genetics with Professor Rosie Redfield
Coursera
A History of the World since 1300!!!! with Jeremy Adelman
Coursera
Microeconomics with Richard McKenzie
Coursera
Discrete Optimization with Professor Pascal Van Hentenryck
Coursera
Leading Strategic Innovation and Creativity in Organizations with David A. Owens, PhD
Coursera
Science from Superheroes to Global Warming with Michael Dennin
Coursera
Introduction to Digital Sound Design with Steve Everett by Emory University
Coursera
Women and the Civil Rights Movement with Dr. Elsa Barkley Brown
Coursera
Galaxies and Cosmology with S. George Djorgovski
Coursera
Science, Technology, and Society in China I, II, and III: Basic Concepts with Naubahar Sharif
Coursera
Introduction to Pharmacy with Kenneth M. Hale, R.Ph., Ph.D.
Coursera
AIDS with Kimberley Sessions Hagen, EdD
Coursera
Health Informatics in the Cloud with Mark Braunstein
Coursera
Songwriting with Pat Pattison by Berklee College of Music
Coursera
Software Defined Networking with Dr. Nick Feamster
Coursera
Epigenetic Control of Gene Expression with Dr Marnie Blewitt
Coursera
Guitar for Beginners - Introduction to Guitar with Thaddeus Hogarth by Berklee College of Music
Coursera
Organizational Analysis with Daniel McFarland
Coursera
Scientific Computing with J. Nathan Kutz
Coursera
Jazz Improvisation - Introduction to Improvisation with Gary Burton by Berklee College of Music
Coursera
Principles of Economics for Scientists with Antonio Rangel
Coursera
Introduction to Music Production with Loudon Stearns by Berklee College of Music
Coursera
Principles of Public Health with Zuzana Bic
Coursera
The Science of Gastronomy with King Chow, Lam Lung Yeung by HKUST
Coursera
The Language of Hollywood: Storytelling, Sound, and Color with Scott Higgins by Wesleyan University
Coursera
Nutrition and Physical Activity for Health with John M. Jakicic, Ph.D., and Amy D. Rickman,...
Coursera
Nutrition, Health, and Lifestyle: Issues and Insights with Jamie Pope, MS, RD, L
Coursera
Survey of Music Technology with Jason Freeman by Georgia Institute of Technology
Coursera
Exercise Physiology: Understanding the Athlete Within with Mark Hargreaves
Coursera
Canine Theriogenology for Dog Enthusiasts with Margaret V. Root
Coursera
Web Intelligence and Big Data with Gautam Shroff
Coursera
Critical Perspectives on Management with Rolf Strom-Olsen
Coursera
El ABC del emprendimiento esbelto with Sergio Ortiz Valdes
Coursera
Interprofessional Healthcare Informatics with Karen Monsen
Coursera
Creativity, Innovation, and Change with Jack V. Matson, Darrell Velegol and Kath
Coursera
Innovacion educativa con recursos abiertos with Maria Soledad Ramirez Montoya an
Coursera
Inspiring Leadership through Emotional Intelligence with Richard Boyatzis
Coursera
Matematicas y movimiento with
Coursera
Sustainability of Food Systems: A Global Life Cycle Perspective with Jason Hill
Coursera
Latin American Culture with Enrique Tames
Coursera
Latin American Culture' with undefined
Coursera
Computer Security with Dan Boneh
Coursera
Introduction to Art: Concepts & Techniques
Coursera
Programmed cell death
Coursera
El ABC del emprendimiento esbelto
Coursera
Understanding economic policymaking
Coursera
History of Rock, Part 1 by University of Rochester
Coursera
Pensamiento Cientifico
Coursera
More on: ML Maths Basics
View skill →Related Reads
📰
📰
📰
📰
Code Challenge of the Day — Reverse word order (easy)
Dev.to · I Want To Learn Programming
Kaggle Titanic: Improving Survival Prediction with Random Forest Age Imputation
Dev.to · kito2718
Kaggle Titanic: Cabin Feature Engineering (Is It Really Effective?)
Dev.to · kito2718
Stop Measuring AI By Parameter Count. Here’s What Actually Matters
Forbes Innovation
Chapters (9)
Introduction – RBF kernel for non-linear SVM classification
0:27
Library Setup – NumPy, Matplotlib, Sklearn tools
0:45
Dataset Generation – Moon-shaped non-linear patterns with noise
1:15
Data Visualization – Why straight lines can't separate moon shapes
1:41
RBF SVM Implementation – Pipeline with standardization and RBF kernel
2:04
Decision Boundary – Visualizing curved classification boundaries
2:46
RBF Power Demonstration – Perfect separation of moon patterns
3:14
Model Evaluation – Train/test split for unbiased assessment
3:33
Results Analysis – 96%
🎓
Tutor Explanation
DeepCamp AI