Training a Support Vector Machine with Linear and Non-Linear Kernels

Linear and non-linear classification with SVMs

Rukshan Pramoditha
5 min readJul 22, 2024

In my previous article, I discussed the theoretical part of support vector machines.

It is strongly recommended that you read that article before continuing to read this one.

Today, we will focus on training support vector machines with linear and non-linear kernels. We will build two support vector classification models using the popular Iris Dataset. We will visualize decision boundaries for each model to get an idea about how well the model separates data points into distinct groups.

Training an SVM classification model with a linear kernel

The most common way to perform SVM linear classification is to use the SVC class with a linear kernel. SVC stands for Support Vector Classification. We will create an instance of the SVC() class with a linear kernel.

First, we need to load the classification dataset. In this case, it is the Iris Dataset which consists of 150 samples of three different variants of iris flowers. So, an SVM classification model will try to put these data points into three different groups.

--

--

Rukshan Pramoditha

3,000,000+ Views | BSc in Stats | Top 50 Data Science, AI/ML Technical Writer on Medium | Data Science Masterclass: https://datasciencemasterclass.substack.com