AIExplainer
Machine Learning Intermediate 2 min read

What is k-median?

A clustering algorithm that partitions data into k clusters based on the median of each cluster

The k-median algorithm is a type of unsupervised machine learning algorithm that groups similar data points into clusters. It works by selecting k initial points, called medians, and then assigning each data point to the cluster with the closest median. The medians are then updated to be the median of all points in each cluster, and the process is repeated until the clusters no longer change.

Imagine you're trying to group a set of cities into regions based on their geographical locations. The k-median algorithm would be like choosing a central city for each region and then assigning each city to the region with the closest central city. The central cities would then be updated to be the city that is most representative of each region, and the process would be repeated until the regions are well-defined.

A company might use the k-median algorithm to group its customers into segments based on their purchasing behavior, allowing them to tailor their marketing efforts to each segment.

The k-median algorithm is commonly used in data analysis and machine learning applications, such as customer segmentation, image compression, and gene expression analysis.

One common misconception about the k-median algorithm is that it is similar to the k-means algorithm, but while both algorithms are used for clustering, the k-median algorithm is more robust to outliers and can handle non-spherical clusters.

The k-median algorithm has its roots in the 1960s, but it wasn't until the 1980s that it became widely used in computer science and statistics.

k-medians median-based clustering partitioning around medians

Three products for different needs — explore what’s relevant to you.