K-Means & Clustering in Unsupervised Learning
Subject: Machine Learning
Master K-Means clustering, centroid initialization, Euclidean distance assignment, centroid updating, the Elbow Method for optimal K, and key limitations in Unsupervised Learning.
Concept Summary
Key Revision Rules & Formulas
- 🎯 Primary Goal of Clustering: Partitioning unlabeled data points into distinct groups (clusters) where points within the same group share high similarity while being distinct from points in other groups.
- ⚡ Centroid-Based Algorithm (K-Means): K-Means represents each cluster by its centroid (mean vector of all points in that cluster). It assigns data points to the nearest centroid using Euclidean distance.
- 🔄 Two-Step Iterative Optimization: 1) Assignment Step: Assign each point to the closest centroid. 2) Update Step: Recalculate each centroid as the mean of all points currently assigned to its cluster.
- 📈 Determining Optimal K (Elbow Method): Plots Within-Cluster Sum of Squares (WCSS / Inertia) vs. number of clusters K. The 'elbow point' where the decrease in WCSS slows down indicates the optimal value for K.
- ⚠️ Sensitivity & Limitations: K-Means is sensitive to feature scaling (requires normalization/standardization), random centroid initialization (can get stuck in local minima), and outliers (which skew centroid means).
- 🔀 Algorithm Categorization: K-Means is a centroid-based technique. Hierarchical Clustering builds a tree (dendrogram), DBSCAN is density-based, GMM is probabilistic, and Apriori is for association rule mining.
Common Exam Pitfalls
- Mistake: Forgetting to scale features before running K-Means. Features with larger scales will dominate Euclidean distance calculations.
- Mistake: Confusing Association Rule Mining algorithms (Apriori, FP-Growth) with Clustering algorithms (K-Means, Hierarchical Clustering).
- Mistake: Expecting standard random initialization to always find global optima. Use K-Means++ initialization to spread initial centroids apart and avoid poor local minima.
- Mistake: Assuming K-Means handles non-spherical or arbitrary cluster shapes well. K-Means assumes spherical clusters of equal size; use DBSCAN or GMM for complex cluster structures.
Sample Practice Questions
Question 1: What is association rule mining?
- Grouping similar data points.
- Finding interesting relationships or associations among items in transactional data.
- Estimating probability density.
- Reducing the dimensionality of data.
Explanation: Association rule mining discovers patterns, such as items frequently co-occurring in transactions (e.g., market basket analysis).
Question 2: What is a frequent itemset in the Apriori algorithm?
- An itemset that appears in at least a minimum number of transactions (support threshold).
- The most common single item.
- An itemset with the highest confidence.
- An itemset that occurs exactly once.
Explanation: An itemset is considered frequent if its support meets or exceeds a user-defined minimum support threshold.
Question 3: Which of the following correctly defines confidence?
- Confidence(A -> B) = P(A∪B) / P(B)
- Confidence(A -> B) = P(A∪B) / P(A)
- Confidence(A -> B) = P(A) / P(A∪B)
- Confidence(A -> B) = P(A∪B) * P(A)
Explanation: Confidence is the conditional probability of B given A: P(B|A) = P(A∪B) / P(A).
Question 4: In the Expectation-Maximization (EM) algorithm for GMM, what does the E-step compute?
- The parameters (means, covariances, mixing coefficients) using the current responsibilities.
- The responsibilities (posterior probabilities) using the current parameter estimates.
- The optimal number of components.
- The initial centroids.
Explanation: The E-step calculates the posterior probability (responsibility) that each data point belongs to each Gaussian component, based on current parameter estimates.
Question 5: Which of the following is a clustering technique?
- Apriori Algorithm
- FP-Growth
- K-Means
- PCA
Explanation: K-Means is a widely used clustering algorithm that partitions data into K distinct clusters.
Question 6: What is single linkage in hierarchical clustering?
- Distance between the farthest points in two clusters.
- Distance between the closest points in two clusters.
- Average distance between all points in two clusters.
- Distance between the centroids of two clusters.
Explanation: Single linkage (or nearest neighbor) uses the minimum distance between any two points in different clusters.
Question 7: Which of the following correctly defines lift?
- Lift(A -> B) = P(A∪B) / (P(A) * P(B))
- Lift(A -> B) = P(A∪B) / P(A)
- Lift(A -> B) = P(A∪B) / P(B)
- Lift(A -> B) = P(A) * P(B) / P(A∪B)
Explanation: Lift measures the ratio of the observed support to the expected support if A and B were independent. Lift = P(A∪B) / (P(A)P(B)).
Question 8: In K-Means, the final clusters depend heavily on:
- The initial centroid selection.
- The distance metric used.
- The number of iterations.
- The support threshold.
Explanation: K-Means is sensitive to initialization; different starting centroids can lead to different local minima and clustering results.
Question 9: K-Means++ is an algorithm for:
- Improving the initialization of K-Means centroids.
- Reducing the number of features.
- Mining association rules.
- Hierarchical clustering.
Explanation: K-Means++ is a smart initialization technique that spreads the initial centroids out to improve convergence and cluster quality.
Question 10: Which of the following is a density-based clustering method?
- K-Means
- Hierarchical Clustering
- DBSCAN
- GMM
Explanation: DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is a prominent density-based clustering algorithm, though not explicitly mentioned in the syllabus, it's a key example of this type.