Cluster validation
Quick answer
Cluster validation asks whether groups are coherent, separated, stable and useful for the task. Internal metrics use geometry without known labels; external metrics compare partitions against independently available reference groups. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 SciPy 1.17.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Calculate silhouette for a point
Observed local output:
0.6The nearest alternative cluster is farther away on average.
How it works
For a point i, let a be its average distance to other members of its own cluster and b the smallest average distance to another cluster. Silhouette s=(b-a)/max(a,b); positive values suggest closer own-cluster neighbors, near zero indicates overlap, and negative values suggest another cluster is closer on average. For a=2,b=5, s=0.6. Standard silhouette assigns zero to singleton members and requires at least two labels and fewer labels than points. Average over points for the overall score. Geometry favors some cluster shapes, so a curved but meaningful group can score worse than an artificial convex split. If DBSCAN returns -1, choose and disclose whether noise is excluded: this chapter evaluates assigned rows only and reports coverage = assigned/total plus noise count; scores on different subsets are not directly comparable. If known synthetic reference groups exist, adjusted Rand index (ARI) compares whether pairs are co-assigned and adjusts for chance; 1 means identical partitions up to renaming, around zero is chance-like and negative values are possible. ARI can include -1 as a label mathematically, but this chapter uses the same assigned subset as silhouette and reports full-partition ARI separately for transparency. Do not use ordinary classification accuracy on arbitrary IDs. Without known labels, inspect geometry, sensitivity to parameters, stability across seeds or resamples, and usefulness for the actual decision. Do not choose a downstream model using final test data, even if clustering itself is unsupervised. This chapter is an exploratory descriptive experiment on fixed toy datasets, not a held-out prediction benchmark.
Check label permutation invariance
from sklearn.metrics import adjusted_rand_score,silhouette_scorex=[[0],[1],[9],[10]]; a=[0,0,1,1]; b=[8,8,3,3]print(adjusted_rand_score(a,b))print(round(silhouette_score(x,a),4),round(silhouette_score(x,b),4))Observed local output:
1.00.8885 0.8885The two partitions have identical membership even though the IDs differ.
Common mistakes
Do not compute silhouette for one cluster or all singleton clusters; report undefined instead. Do not silently drop DBSCAN noise or compare subset scores as though they used identical rows. Avoid declaring one clustering algorithm universally superior from a single fixture.
Practice and next steps
Compute silhouette for a=4,b=2 (answer -0.5). Swap all cluster IDs in the example and verify ARI remains one. Then compare the chapter project’s plots, coverage and metrics and explain any disagreement. Complete the knowledge check and staged exercise. Next: Dimensionality reduction and manifold learning.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Cluster validation — knowledge check
Apply cluster validation to new scenarios.
What is silhouette when a=2 and b=5?
What happens to ARI if IDs are renamed consistently?
How should DBSCAN noise exclusion be reported?
Can silhouette be computed for one label?
Can a useful nonconvex grouping have lower silhouette?