Centroid Neural Network: An Efficient and Stable Clustering Algorithm
Last Updated on August 19, 2021 by Editorial Team
Author(s): LA Tran
Deep Learning
Letβs upraise potentials that are not paid much attention
Generally, clustering is grouping multi-dimensional datasets into closely related groups. Classical representatives of clustering algorithms are K-means Clustering and Self-Organizing Map (SOM). You can easily find numerous resources for those algorithm explanations. This time, let me introduce to all of you another efficient clustering algorithm but seemingly no many researchers pay attention: Centroid Neural Network for Unsupervised Competitive Learning. Please click here to have a closer looking at the originalΒ paper.
And now, letβs getΒ started!
Centroid Neural NetworkΒ (CentNN)
To avoid confusion with Convolution Neural Network, I would like to use the term βCentNNβ in thisΒ post.
CentNN is an unsupervised competitive learning algorithm based on the classical k-means clustering algorithm that estimates centroids of the related cluster groups in training date. CentNN requires neither a predetermined schedule for learning coefficient nor a total number of iterations for clustering. In the paper, the simulation results on clustering problems and image compression problems show that CentNN converges much faster than conventional algorithms with compatible clustering quality while other algorithms may give unstable results depending on the initial values of the learning coefficient and the total number of iterations.
The above figure shows the CentNN algorithm. If you get bored when looking at all those mathematical equations, donβt worry, I am going to make it more understandable with a secondary-school-maths example.
Weight Update
The core of the algorithm is the weight update procedure: How to calculate efficiently the centroid of a group of data points when a single data point moves in orΒ out?
For instance, we have 100 integers, itβs very simple to calculate the mean value by averaging all of them. Then what happens if we have one more integer? Do we need to average all 101 those ones again? The answer isΒ NO!
Letβs say we have N and N+1 data points, the mean value w is calculated asΒ follows:
From the 2 above equations:
Now we can calculate the mean of 101 integers without averaging all of them again. Itβs similar when we move out one integer to have 99 integers.
And the example above explains these equations in theΒ paper:
Visual Explanation Example
Given a dataset with 30 data points as the figure below, our aim is to cluster them into 3 clusters.
Epoch 0: Initialization
Find 1 centroid c for all data, then split c into 2 weights w1, w2 with a smallΒ Ζ.
w1 = c + Ζ, w2 = cβββΖ (e.g. Ζ = 0.05Β )
Before going ahead, letβs talk about the term βwinner neuronβ and βloserΒ neuronβ.
- winner neuron: input a data x, the winner neuron is the weight (w) which is closest to x among allΒ weights.
- loser neuron: input a data x at epoch n, if in epoch (n-1), w was the closest weight to x, but in epoch n, there is another weight wβ which is closer to x than w, then w is a loser neuron and wβ is a winner neuron for the data x at epochΒ n.
Find the winner neuron for each x inΒ X.
- x1 comes, w1 wins β updateΒ w1
- x2 comes, w2 wins β updateΒ w2
- x3 comes, w1 wins β updateΒ w1
- β¦
- x30 comes, w1 wins β updateΒ w1
After epoch 0, we always have 2 centroids and information of clustered data points. Now, keep itΒ here:
- x1 comes, w1Β wins
- x2 comes, w2Β wins
- x3 comes, w1Β wins
- β¦
- x30 comes, w1Β wins
Epoch 1:
Find the winner neuron for each x inΒ X.
- x1 comes, w2 wins β w1 loses, loser += 1, updateΒ weights.
- x2 comes, w2Β wins
- x3 comes, w1Β wins
- β¦
- x30 comes, w1Β wins
After epoch 1, we have 1 data whose cluster is updated, and the number of loser neurons increases by 1. By looking, we can still realize that x1 is closer to w2 rather than w1, but at epoch 0, x1 was clustered to w1, now it is updated correctly. Again, keep the information here:
- x1 comes, w2Β wins
- x2 comes, w2Β wins
- x3 comes, w1Β wins
- β¦
- x30 comes, w1Β wins
Epoch 2:
Keep finding the winner neuron for each x inΒ X.
- x1 comes, w2Β wins
- x2 comes, w2Β wins
- x3 comes, w1Β wins
- β¦
- x30 comes, w1Β wins
Now, nothing changes. Letβs check if the number of clusters now reaches the desired number of not. The answer is NOT YET. Then we start splitting the centroid with the most error with a smallΒ Ζ.
Now do the same procedure from epochΒ 1.
Epoch 3:
Epoch 4:
Epoch 5:
Now, nothing changes, and we also reach the desired num of clusters. Now, time toΒ party!
Below is the comparison between the results of K-Means Clustering and CentNN in image compression. We can see that CentNN outperforms K-Means Clustering in terms of PSNR (peak signal-to-noise ratio), with PSNR 47.53 compared to PSNR 46.35, respectively. In the example, the image size is 128×128, the number of clusters isΒ 48.
CentNN Implementation
You guys can find my implementation of CentNN in Python here. If you feel it helps, please do not hesitate to give it aΒ star.
By the way, you are welcome to visit my Facebook page which is for sharing things regarding Machine Learning: Diving Into Machine Learning.
In this post, I have introduced to all of you Centroid Neural Network (CentNN), an efficient clustering algorithm. The main feature of CentNN is that it updates weights every time a single new data comes, while K-means Clustering updates centroids after every iteration.
In order to avoid the algorithm from getting stuck at an undesirable local minimum solution, CentNN starts with setting the number of groups to two and increases the number of groups one by one until it reaches the predetermined number of groups. The CentNN algorithm does not provide any guarantee of convergence to the global minimum solution like other unsupervised algorithms but does provide a guarantee of convergence to a localΒ minimum.
Centroid Neural Network: An Efficient and Stable Clustering Algorithm was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.
Published via Towards AI