Home Artificial Intelligence Creating Animation to Show 4 Centroid-Based Clustering Algorithms using Python and Sklearn

Creating Animation to Show 4 Centroid-Based Clustering Algorithms using Python and Sklearn

2
Creating Animation to Show 4 Centroid-Based Clustering Algorithms using Python and Sklearn

Using data visualization and animations to grasp the strategy of 4 Centroid-based clustering algorithms.

Photo by Mel Poole on Unsplash

Clustering evaluation is an efficient machine learning technique that groups data by their similarities and differences. The obtained data groups will be used for various purposes, similar to segmenting, structuring, and decision-making.

To perform clustering evaluation, many methods can be found based on different algorithms. This text will mainly concentrate on centroid-based clustering, which is a typical and useful technique.

Mainly, the centroid-based technique works by repeatedly calculating to acquire optimal centroids (cluster centers) after which assigning data points to the closest ones.

As a result of having many iterations, data visualization will be used to specific what happens throughout the process. Thus, the aim of this text is to create animations to point out the centroid-based process with Python and Sklearn.

An example of a clustering animation in this text. Image by Creator.

Sklearn (Scikit-learn) is a strong library that helps us perform clustering evaluation efficiently. The followings are the centroid-based clustering techniques that we are going to work with.

  1. K-means clustering
  2. MiniBatch K-means clustering
  3. Bisecting K-means clustering
  4. Mean-Shift clustering

Let’s start

Start with importing libraries.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

For instance, this text will use a generated dataset, which will be easily created using sklearn’s make_blobs(). If you may have your dataset, this step will be skipped.

from sklearn.datasets import make_blobs
X, y…

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here