Member-only story

Linear Support Vector Machines in Python

Step-by-step follow along | Data Series | Episode 9.2

Mazen Ahmed
3 min readJun 5, 2021

An explanation of linear Support Vector Machines: Episode 9.1

How to set up your programming environment can be found at the start of :
Episode 4.3

You can view and use the code and data used in this episode here: Link

Objective

Produce a linear support vector machine that is a able to classify apples and oranges based on weight and size.

Importing and exploring our Data

import pandas as pd

apples_oranges = pd.read_csv("D:\ProjectData\\apples_and_oranges.csv")
apples_oranges.head()
# create a dictionary to colour classes 
color_dict = dict({'orange':'orange',
'apple':'green'})
# scatterplot
plt.title('Sizes and Weights of apples and oranges')
sns.scatterplot(data=apples_oranges, x="Weight", y="Size", hue="Class", palette = color_dict)

--

--

Mazen Ahmed
Mazen Ahmed

No responses yet