Reader small image

You're reading from  Interactive Dashboards and Data Apps with Plotly and Dash

Product typeBook
Published inMay 2021
Reading LevelBeginner
PublisherPackt
ISBN-139781800568914
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Elias Dabbas
Elias Dabbas
author image
Elias Dabbas

Elias Dabbas is an online marketing and data science practitioner. He produces open-source software for building dashboards, data apps, as well as software for online marketing, with a focus on SEO, SEM, crawling, and text analysis.
Read more about Elias Dabbas

Right arrow

Understanding clustering

So, what exactly is clustering and when might it be helpful? Let's start with a very simple example. Imagine you have a group of people for whom we want to make T-shirts. We can make a T-shirt for each one of them, in whatever size required. The main restriction is that we can only make one size. The sizes are as follows: [1, 2, 3, 4, 5, 7, 9, 11]. Think how you might tackle this problem. We will use the KMeans algorithm for that, so let's start right away, as follows:

  1. Import the required packages and models. NumPy will be imported as a package, but from sklearn we will import the only model that we will be using for now, as illustrated in the following code snippet:
    import numpy as np
    from sklearn.cluster import KMeans
  2. Create a dataset of sizes in the required format. Note that each observation (person's size) should be represented as a list, so we use the reshape method of NumPy arrays to get the data in the required format, as follows...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Interactive Dashboards and Data Apps with Plotly and Dash
Published in: May 2021Publisher: PacktISBN-13: 9781800568914

Author (1)

author image
Elias Dabbas

Elias Dabbas is an online marketing and data science practitioner. He produces open-source software for building dashboards, data apps, as well as software for online marketing, with a focus on SEO, SEM, crawling, and text analysis.
Read more about Elias Dabbas