K-Means Simplified [Guide]

Clustering refers to the grouping of data objects or observations into subsets. A cluster is an object that has many objects. However, each subset can be different. A cluster is used to examine a data set to identify its underlying patterns or create a collection of characteristic. Automatic classification is also known as clustering.

A cluster can refer to a group of data which are related to each other within a particular cluster but not to others in the cluster. Therefore, a cluster can be considered an implicit class. Clustering is able to automatically identify the groups. Clustering has a clear advantage. Business intelligence is one example of a wide-spread use for clustering.

Clustering is a method of organizing large numbers of customers into small groups that share similar traits. This makes it easier to create business strategies that will improve customer relationships management. Different clustering algorithms may produce different clusterings from the same set of data. Clustering algorithms such as K-means perform the grouping. Clustering can be useful because it may lead to discovery of previously undiscovered groups in the data.

What’s K-means?

K-means, a widely-used algorithm for clustering, is well-known. K-means assumes that there are at least k groups within our data set. The next step is to try and group those data into the k groups. A centroid is the single point that describes each group. A cluster’s centroid is the average value of all points in the group. What does K-means do? It creates randomly k centroids, where k represents the number of clusters we want to target. Based on the euclidean distances between the sample and the cluster centroid, each sample is assigned to the closest cluster.

It then updates each centroid with the average of the sample. The updated centroids are used to reassign all the samples. Iterations will continue until an assignment is made that is both stable and does not differ from the prior assignment. This is how the k-means procedure works: Select the number of clusters. Start k numbers of centroids. Each sample should be assigned to the nearest centroid based upon its euclidean distance.

The mean value of each sample is used to update the cluster’s new centroid. Each sample should be assigned to the new centrroid. Reassign each sample to the new centroid if there was a reassignment. Otherwise, stop iterating. This is an example of a dummy data set containing 10 sample data. Photo by me. Step 2: Initialize Centroid. Let’s say that we wish to divide the data into two clusters. Step 2: Create a Centroid. Photo: me. Step 3: Align each sample with the nearest centroid. Based on previous euclidean distances, this formula is applied to our data.

Step 4: Update new centroid. We update the centroid by using the average of each assigned sample from each cluster. Photo by me. Scatter plot the data: Photo: me. Step 5: Assign each sample to a new centroid. If there was a reassignment, go back to step 4. Otherwise it will stop. If there was a reassignment, go back to step 4 or stop the iteration. The mean of each assigned sample from each cluster is used to update the centroid.

Each sample should be assigned to the nearest centroid based upon previously established euclidean separation. Photo: me. Photo: Scatter plot. Photo: me. Photo: me. Photo: me. 2 Assignments occur, so we return to step 4. Photo: me Update the centroid by using the average of each assigned sample from each cluster. Photo: me Photo: me Scatterplot: Photo: me Photo: me Scatterplot: Final Result.

The kā€“means algorithm does not guarantee that it will converge at the global optimum. It often ends up close to its local optimum. It is important to know the origin centroid of your results. It is popular to use the k-means algorithm multiple times, with different initial centroids and different k clusters.

This will give you better results. Refer to [1] J. Han and M. Kamber and J. Pei Data Mining Concepts and Techniques (2011)[2] Sung Soo Kim. What is Cluster Analysis? (2015) Simplified originally appeared in on Medium. People are responding and highlighting this story. Published via


We monitors and writes about new technologies in areas such as technology, innovation, digitization, space, Earth, IT and AI.

Related Posts

Leave a Reply