Prerequisite: K-Means Clustering | Introduction
There is a popular method known as elbow method which is used to determine the optimal value of K to perform the K-Means Clustering Algorithm. The basic idea behind this method is that it plots the various values of cost with changing k. As the value of K increases, there will be fewer elements in the cluster. So average distortion will decrease. The lesser number of elements means closer to the centroid. So, the point where this distortion declines the most is the elbow point.
In the above figure, its clearly observed that the distribution of points are forming 3 clusters. Now, let’s see the plot for the squared error(Cost) for different values of K.
Clearly the elbow is forming at K=3. So the optimal value will be 3 for performing K-Means.
Another Example with 4 clusters.
Corresponding Cost graph-
In this case the optimal value for k would be 4. (Observable from the scattered points).
Below is the Python implementation:
- Elbow Method for optimal value of k in KMeans
- Silhouette Algorithm to determine the optimal value of k
- DBSCAN Clustering in ML | Density based clustering
- ML | Hierarchical clustering (Agglomerative and Divisive clustering)
- K means Clustering - Introduction
- Analysis of test data using K-Means Clustering in Python
- ML | Unsupervised Face Clustering Pipeline
- ML | Mini Batch K-means clustering algorithm
- ML | Mean-Shift Clustering
- Implementing Agglomerative Clustering using Sklearn
- ML | OPTICS Clustering Implementing using Sklearn
- ML | OPTICS Clustering Explanation
- ML | V-Measure for Evaluating Clustering Performance
- ML | Spectral Clustering
- ML | Types of Linkages in Clustering
- Python | Clustering, Connectivity and other Graph properties using Networkx
- ML | BIRCH Clustering
- Image Segmentation using K Means Clustering
- Choose optimal number of epochs to train a neural network in Keras
- Determine the type of an image in Python using imghdr
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.