k means clustering is a unsupervised machine learning algorithm , you will use it to create clusters based on what the machines sees in the data.
Example :- All kids of various heights and weight in creche are playing with each other and in each break they would self organize into different groups of friends.
These kids have to be assigned to 3 learning groups so that it is easier for kids to mingle. So in k means clustering k=3 in this case as we need to divide the kids into 3 groups
Now, Imagine that the machine learning algorithm gets started , to start the machine puts 3 colors pink , blue and yellow on three random kids . Each cluster represents a potential cluster based on their social group.
This will be my 3 centroid kids , now each of the centroid kid will look at the mean distance between itself and all of the surrounding kids then the machine will put same color tagging to the kid that are closest to these centroid kid , since these centroids kids were selected randomly there is a pretty good chance that you won’t have any good cluster, may be each 3 centroids where in the same social group , if that happens then many kids will have large distance from the centroid kids . So the machine will try over and over again until it picks the best centroid kid , it might also do this one cluster at a time . At the end of each iterations , the machine learning algorithm checks the variance between each kids and the centroid. once you have good centroid kid, then it is pretty straight forward to put unknown kid in each cluster. The iterations repeats until the clusters no longer change.
if you put new kid in creche you can easily tell which social group it ends in just by measuring the distance with the centroid kids. The kids might not themselves group into 3 groups , they might have grouped in 5-6 groups but the crèche requires them to be in 3 groups , so the machine learning algorithm has to do its best to create 3 cluster that best represent kids social grouping
Challenge to k means, it can be very sensitive to outliers , so if you have a kid that is not interested in hanging out with any of the other kids, but it will still be clustered into one of 3 groups, that means it will be forced to find a friend.
One of most interesting business applications , is when retailers use clustering to decide who gets promotional offers , they may create 3 clusters like loyal, somewhat loyal and lowest priced shopper, then they will create strategy to elevate somewhat loyal customers to loyal customer or can invite loyal customer to participate in one of their programs
Organizations are looking for better ways to cluster together their customers , if you can get all your loyal customers in one cluster than that can really help the business.