A good clustering has tight clusters that sit far from one another. The Calinski-Harabasz index (also called the variance ratio criterion) makes that precise: it compares between-cluster dispersion with within-cluster dispersion, each scaled by its degrees of freedom. Higher means a better-defined partition.
Implement calinski_harabasz_index(X, labels).
ValueError.inf.Open one at a time. Each gives away a little more than the last.
Compute the overall mean once, then each cluster's centroid and size with a boolean mask.
Squared distances are cheaper to sum than distances here. np.sum((A - B) ** 2) works on the whole cluster at once.
No results yet
Run your code to check it against the examples, or submit to run every test.