NEW
Also known as: K-Means Clustering
Iterative clustering algorithm assigning points to nearest centroids and updating centroids to minimize within-cluster variance.
DESCRIPTION
K-means partitions data into k clusters by alternating assignment and centroid update until convergence. It minimizes sum of squared distances within clusters, typically using Euclidean distance. Initialization matters; k-means++ improves stability and speed. The algorithm assumes roughly spherical, similarly sized clusters and benefits from feature scaling. Model selection often uses elbow or silhouette analysis to choose k.
ALTERNATIVE DEFINITIONS
Wikipedia
k-means clustering is a method of vector quantization that aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean.
Classic definition connecting k-means to vector quantization and nearest mean.
scikit-learn
K-means clustering aims to partition n samples into k clusters by minimizing the within-cluster sum-of-squares criterion.
Emphasizes the optimization objective used in practice.
RELATED TERMS
Cluster Analysis Centroid Euclidean Distance Elbow Method Silhouette Score Hierarchical Clustering
COMPETING TERMS
KNOWLEDGE AREAS
TARGET AUDIENCE
Data Scientist AI Engineer Data Analyst
EXTERNAL SOURCES
- Wikipedia - K-means clustering
- scikit-learn - Practical guide and API for k-means
- Google Developers - Educational overview of k-means
TOP QUESTIONS
When should K-means be used for clustering?
Use k-means for well-separated, roughly spherical clusters with similar variance and when Euclidean distance is meaningful.
Category: Best practices
How do you choose k in K-means?
Use the elbow method, silhouette score, or domain knowledge to balance cluster compactness and interpretability.
Category: How-to
What are common mistakes with K-means?
Not scaling features, poor initialization, and using it on non-convex or varying-density clusters often cause poor results.
Category: Mistakes
How does k-means++ improve K-means?
It initializes centroids to be well separated, speeding convergence and improving clustering quality.
Category: Concept
Is K-means deterministic?
No. Random initialization yields different results; using multiple initializations and a fixed random seed helps.
Category: Misunderstanding
How does K-means handle categorical features?
It doesn’t natively; consider encoding or use algorithms designed for categorical data (e.g., k-modes).
Category: Alternatives
What metrics evaluate K-means clustering?
Silhouette score, Davies–Bouldin index, Calinski–Harabasz score, and within-cluster sum of squares.
Category: How-to
How to speed up K-means on large datasets?
Mini-batch k-means, dimensionality reduction, efficient initialization, and parallelization reduce runtime.
Category: Performance
What are alternatives to K-means for irregular clusters?
DBSCAN and spectral clustering handle non-convex shapes and varying densities better.
Category: Alternatives