PythiloLesson 12 of 12 · progress kept in this browser

Silhouette Clustering Score

A cluster assignment can be compact yet poorly separated. Compare each point’s mean distance within its cluster with the nearest other cluster; singletons score zero.

within, nearest_other = 1.0, 9.5
print((nearest_other-within)/max(within, nearest_other))
Your task

silhouette(points, labels) returns the mean silhouette for 1D points using absolute distance. There are at least two nonempty clusters. A singleton has score 0; if a=b=0 also use 0.

All lessons