Compares a semi-supervised approach (Label Spreading) against a fully unsupervised baseline (KMeans) on the sklearn handwritten digits dataset. Simulates a realistic scenario where only 20% of data carries labels — common in medical imaging, fraud detection, and network anomaly detection.
| Method | Accuracy on Unlabelled Data |
|---|---|
| Label Spreading (KNN kernel, α=0.8) | ~90% |
| KMeans (unsupervised baseline) | n/a — no label info |
Label Spreading consistently outperforms purely unsupervised clustering when even a small fraction of labels is available.
- Label Spreading — graph-based semi-supervised algorithm that propagates known labels to unlabelled samples through a KNN similarity graph
- Must-Link / Cannot-Link constraints — pairwise constraints that guide clustering without requiring full labels
- Elbow Method — WCSS plotted against K to select the optimal number of clusters
- Cluster distribution across 10 KMeans groups
- Elbow curve (WCSS vs K) for cluster selection
- Must-Link vs Cannot-Link constraint illustration
Python · scikit-learn · NumPy · Matplotlib
pip install numpy matplotlib scikit-learn
mkdir results
python main.py