M2-054M2: Classical Machine LearningClustering AlgorithmsMedium
⚡Flashcard Drill➔Mastery:
Compare K-Means, Gaussian Mixture Models (GMM), and DBSCAN Across Assumptions, Geometry, and Complexity
📐 Mathematical Definition
⚡ One-Sentence Core Answer
K-Means enforces hard spherical partitions; GMM provides probabilistic soft clustering with ellipsoidal covariance; DBSCAN discovers arbitrarily shaped density clusters without pre-specifying and naturally isolates noise.
📌 Key Takeaways
- •K-Means: Hard assignment; spherical clusters; requires pre-specifying ; sensitive to outliers; time.
- •GMM: Soft assignment (posterior probability ); arbitrary ellipsoidal covariance matrices ; requires pre-specifying ; fits via EM algorithm.
- •DBSCAN: Density-based (core points, border points, noise); arbitrarily shaped clusters; does NOT require specifying ; robust to noise; requires .
📐 Mathematical Derivations
Structural comparison of boundary definitions: (1) K-Means boundary: Voronoi diagram of hyperplanes equidistant between centroids . (2) GMM boundary: Quadratic decision boundaries determined by log-odds: . (3) DBSCAN density connectivity: A point is a Core Point if . Point is directly density-reachable from if and is a core point. A cluster is a maximal set of density-connected points; any point not density-reachable from any core point is labeled Noise ().
🏭 Production Trade-offs
When to choose which: (1) K-Means: Massive datasets where fast computation and hard segmentation are required (e.g. Image color quantization, vector quantization). (2) GMM: Overlapping clusters where uncertainty quantification matters (e.g. Financial regime modeling, speaker identification). (3) DBSCAN: Spatial geo-data, GPS trajectory analysis, and anomaly detection where clusters have arbitrary non-linear shapes (crescents, rings) and noise must be filtered.
⚠️ Common Interview Pitfalls
- ✕Using DBSCAN on datasets with wildly varying cluster densities (a single global cannot capture both dense and sparse clusters; HDBSCAN must be used).
- ✕Using K-Means on concentric ring or crescent-shaped data (K-Means will cut rings in half linearly).
🎯 Interviewer Follow-up Inquiries
- ?How does HDBSCAN extend DBSCAN to multi-scale hierarchical densities without tuning epsilon?
- ?Why does full-covariance GMM require estimating parameters, and how do tied or diagonal covariance constraints mitigate overfitting?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
📚
Associated Knowledge Base Guides & Mindmaps
Explore the comprehensive technical article, exam cards, and global architecture tree.
中文速览与面试要点
比较 K-means、GMM(EM)与 DBSCAN。
K-means 硬分配+球形;GMM 软分配+椭圆+概率模型;DBSCAN 密度聚类,可发现任意形状与噪声。
核心要点
- 三者假设与能力对比:① K-means ——硬分配(每点属于一个簇)、隐式假设球形等方差簇、目标是最小化簇内平方和;优点是简单快速(O(nKd) 每次迭代)、可扩展;缺点是无法表达簇的形状/大小差异、对初始化与异常值敏感、需预先指定 K。② GMM ——软分配(每点以概率属于各簇)、假设每簇为高斯分布(可学协方差矩阵 → 椭圆簇)、用 EM 最大化似然;优点是可给出后验概率(不确定性)、能表达椭圆与重叠簇、可用 BIC 选 K;缺点是对初始化敏感(可能收敛到局部最优)、协方差矩阵参数量 O(Kd²)(高维下需约束为对角/球形)、对异常值敏感。③ DBSCAN ——基于密度(核心点:邻域内点数 ≥ minPts;密度可达的点连成簇), 无需指定簇数 、能发现 任意形状 的簇、天然识别噪声点;缺点是对参数(eps、minPts) 极其敏感 (eps 稍变结果剧变)、对密度差异大的数据失效(单一 eps 无法适应多密度)。
- 实践选择与联系:① EM 与 K-means 的关系 ——K-means 是 GMM 的 极限情形 :当 GMM 的所有协方差矩阵固定为 σ²I 且 σ→0 时,后验概率趋于 one-hot(软分配退化为硬分配),EM 退化为 K-means。这解释了为什么 K-means 是'硬'GMM。② 选择依据 ——数据量大、簇近似球形 → K-means;需概率输出或椭圆簇 → GMM;簇形状任意、含噪声 → DBSCAN;密度差异大 → HDBSCAN (层次化 DBSCAN,自动适应多密度,无需 eps)。③ 评估 ——有标签时用 ARI/NMI;无标签时用轮廓系数(凸簇)、Calinski-Harabasz、Davies-Bouldin;但 无标签指标偏向凸簇 ,对 DBSCAN 的结果可能给出误导性低分。④ 高维问题 ——所有基于距离的方法在高维下都受维度灾难影响,聚类前应降维(如先 PCA 到 10–50 维)。
- GMM 用 EM 优化,可给后验概率
- DBSCAN 无需指定 K,但对密度参数敏感
常见陷阱
- 用 K-means 处理环形/非凸簇
- 对密度差异大的数据用单一 eps 的 DBSCAN