Clustering is an unsupervised learning technique that groups similar data points together without predefined labels. Unlike classification (supervised), clustering discovers natural structures in data.
K-Means is the most widely used partitioning algorithm. It partitions n data points into k clusters by minimizing the within-cluster sum of squares (SSE).
The Elbow Method helps determine the optimal k. Plot SSE vs k — the "elbow" where SSE stops decreasing significantly indicates the best k.
K-Means is sensitive to outliers because centroids are calculated as means. A single outlier can shift the centroid significantly. K-Medoids (PAM) is more robust — it uses actual data points as cluster centers.
Hierarchical clustering builds a tree of nested clusters (dendrogram). You can cut the tree at different levels to get different numbers of clusters.
Linkage determines how the distance between two clusters is calculated:
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) groups together closely packed points and marks outliers in low-density regions.
Evaluating clustering quality is crucial because there are no ground-truth labels in unsupervised learning.