How to Evaluate Your Classification Algorithm in Python

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

Mazen Ahmed
3 min readDec 9, 2021

In the previous episode, we went over the different methods you can use to evaluate your classification algorithm.

In this episode, we focus on applying these methods in Python.

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

1. Building the Classification Algorithm

First we need to build a classification algorithm to evaluate. In this case, we are going to be evaluating the non-linear support vector machine built in episode 9.3.

You can copy and paste the following code into your Python script.

Ensure you save the data and change the file path to where your data is saved.

import warnings
warnings.filterwarnings("ignore")

import pandas as pd
# read data
star_data = pd.read_csv("D:\ProjectData\pulsar_data.csv")

# drop rows containing missing values
star_data.dropna(inplace = True)

# remove spaces in column headings
star_data.columns = star_data.columns.str.strip()

# define input (X) and outpit (y) data of the algorithm
X = star_data.drop('target_class', 1)
y = star_data['target_class']

# perform data standardization
from…

--

--

Mazen Ahmed
Mazen Ahmed

Responses (1)