How to Create a Cluster Map in Seaborn

01.29.2021

Intro

Clustering is a common machine learning topic and can become very complex. However, Seaborn provides a nice quick clustermap to give you are sense of groups. In this article, we will learn how to create a cluster map in the Seaborn Library.

Creating a Cluster Map

To create a cluster map, we use the clustermap method. We pass it a data set, and Seaborn will attemp to categorize contious vairables by categorical variables. In the example below, we use the iris data set. We remove the species categorical variable so only one category is left to group by.

import seaborn as sns

iris = sns.load_dataset("iris")

species = iris.pop("species")

sns.clustermap(iris)