Level 1 · foundational · ~5 h
Spectral clustering from a k-NN Laplacian — controlled synthetic benchmark
Recover the ten digit communities of MNIST without using labels when building the affinity graph, and compare with k-means on raw pixels. Use a fixed seed, a controlled ground truth, and an ablation grid over the key hyperparameter.
Prerequisites
Problem statement
- 01Recover the ten digit communities of MNIST without using labels when building the affinity graph, and compare with k-means on raw pixels. Use a fixed seed, a controlled ground truth, and an ablation grid over the key hyperparameter.
Real-world motivation
- 01Eigenvectors of a graph Laplacian expose manifold structure that Euclidean k-means cannot see. The controlled synthetic benchmark setting forces concrete choices about data, scale and evaluation.
Learning objectives
- 01Build a sparse k-NN affinity graph
- 02Compute the normalized Laplacian eigenvectors
- 03Evaluate cluster quality against labels
- 04Report relative error against the analytic ground truth alongside the baseline metrics.
Technical architecture
- 01sparse k-NN graph with adaptive Gaussian kernel
- 02L_sym = I - D^-1/2 A D^-1/2
- 03row-normalize eigenvectors then run k-means
Mathematical foundations
- 01$A_{ij}=\exp(-\lVert x_i-x_j\rVert^2/(\sigma_i\sigma_j))$ for mutual k-NN pairs
- 02$\min_{Y^\top Y=I}\mathrm{tr}(Y^\top L_{sym}Y)$ solved by the bottom eigenvectors
Dataset and sources
- 01synthetic matrices generated with numpy.random.default_rng(42)
- 02condition numbers 1, 10, 100, 1000
Step-by-step tasks
- 01Frame the task and freeze the controlled synthetic benchmark evaluation protocol with a fixed random seed.
- 02Implementation 1: Build A with scipy.sparse and mutual 10-NN
- 03Implementation 2: Select sigma by the median heuristic
- 04Implementation 3: Use eigsh(k=11, which='SM') and cluster the rows of Y
- 05Verification 1: Assert all eigenvalues of L_sym are nonnegative
- 06Verification 2: Check Y.T @ Y is within 1e-5 of identity
- 07Run the ablation grid and report relative error against the analytic ground truth over three independent trials.
Implementation requirements
- 01Build A with scipy.sparse and mutual 10-NN
- 02Select sigma by the median heuristic
- 03Use eigsh(k=11, which='SM') and cluster the rows of Y
- 04Log all hyperparameters and the random seed for the controlled synthetic benchmark run.
Testing requirements
- 01Assert all eigenvalues of L_sym are nonnegative
- 02Check Y.T @ Y is within 1e-5 of identity
- 03Measure relative error against the analytic ground truth over at least three seeds.
Evaluation metrics
- 01NMI
- 02ARI
- 03cluster purity
- 04relative error against the analytic ground truth
Expected outputs
- 01cluster assignments
- 02eigenvalue spectrum plot
Common failure modes
- 01disconnected graph yields trivial components
- 02sigma too small isolates every point
- 03ill-conditioning above 1e3 makes double precision futile
Stretch goals
- 01add a Nyström out-of-sample extension
- 02compare with UMAP embeddings
- 03repeat in float32 and quantify the extra error floor
Research extensions
- 01derive a consistency rate for k-NN affinity under sampling
- 02study spectral clustering with corrupted affinity edges
GitHub submission requirements
- 01A repository whose README states the controlled synthetic benchmark protocol and the exact command to reproduce it.
- 02Source for the scratch implementation, a test file, and a results table with uncertainty estimates.
- 03A two-page report explaining failures on synthetic matrices generated with numpy.random.default_rng(42) and what the ablation revealed.
Completion rubric
- 01correct sparse Laplacian construction
- 02justified sigma selection
- 03NMI within 3 points of the reference
- 04Extra credit: repeat in float32 and quantify the extra error floor
Submit when every rubric item is satisfied and your repository contains runnable code plus a reproduction command.