Lesson Introduction

Welcome to our lesson on Support Vector Machines (SVM)! Today, we will learn about a powerful tool used for classifying data in machine learning. Have you ever thought about how a computer could tell the difference between pictures of cats and dogs? SVM is one way to make that possible by drawing a line, or more accurately, a hyperplane, to separate different categories. By the end of this lesson, you’ll be able to load a dataset, split it into training and testing sets, and train an SVM model using Python and Scikit-Learn. Let’s get started!

Introduction to SVM

First, let’s talk about what an SVM is. Imagine you have a bag full of apples and oranges on a table. You want to separate them into two groups using a straight line. This line that separates the two groups in such a way is called a hyperplane. SVM is a classification algorithm that finds the best hyperplane that separates different classes in the data.

But wait, what if the data can’t be separated by a straight line? That’s when SVM can use something called a kernel trick to transform the data into a higher dimension where a hyperplane can be used. The data points that are closest to the hyperplane are called support vectors because they “support” the hyperplane. Essentially, SVM seeks to maximize the margin between the classes through the hyperplane, leading to better generalization in classification.

Here is an example image:

Dots of different classes are separated using the hyperplane (which is just a line in this 2d case), which we call the "decision boundary". The closest samples form the support vectors, drawn as dashed lines. They help to keep the decision boundary in the optimal equally-distanced position.

In Python, we use the SVC class from the Scikit-Learn library to create an SVM.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal