An unsupervised machine learning algorithm that partitions a dataset into `k` distinct clusters based on their similarity or dissimilarity with respect to certain features or attributes, aiming to minimize the total within-cluster variance.
Suppose we have a dataset of customer purchases from an online retailer. We can use k-means clustering to group customers into clusters based on their buying behavior, such as preferring luxury brands or frequently purchasing items in a particular category. This could help the retailer tailor its marketing and product offerings to better serve each cluster of customers.