All problems
Davies-Bouldin Lite
Problem
Compute the Davies-Bouldin index for exactly two clusters: (spread_0 + spread_1) / distance(centroid_0, centroid_1), where spread is the mean Euclidean distance of cluster members to their centroid.
Return 0.0 if there are not exactly two clusters, the centroids coincide, or input is empty.
Hint
Compact, well-separated clusters give a small Davies-Bouldin index.
Test cases
case 1
in: [[[0,0],[1,0],[10,0],[11,0]],[0,0,1,1]]
expected: 0.1
case 2
in: [[[0],[1],[2],[10]],[0,0,0,1]]
expected: 0.07407407407407407
case 3
in: [[[0,0],[1,1]],[0,0]]
expected: 0
case 4
in: [[],[]]
expected: 0
Starter codePython
def davies_bouldin_2(points, labels):
# Your code here
pass4 test cases · run your code against them in the editor