Member-only story
K-means Clustering in Python
Step-by-step follow along | Data Series | Episode 8.2
4 min readNov 26, 2020
An explanation of the K-means clustering algorithm: Episode 8.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
Place the following data taken from iris plants into clusters to see if we can identify different plants given their petal width and sepal length:
Importing and exploring our Data
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
# read data into variable Iris_data
Iris_data = pd.read_csv("D:\ProjectData\Iris.csv")
#display first few rows of data
Iris_data.head()