You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a Euclidean Davies-Bouldin variant matching scikit-learn #137
The current DB uses mean squared distance within each cluster and squared distance between centroids. sklearn.metrics.davies_bouldin_score uses Euclidean distances for both. This makes the existing DB score a related metric, not a numerically equivalent reference in the timing benchmark (#120, #126).
Scope
Add a clearly named Euclidean DB variant while preserving the current DB definition and behavior.
Match scikit-learn's score on valid labeled batches, including its handling of degenerate clusters and coincident centroids where applicable.
Determine and document which incremental and structural operations can maintain exact Euclidean within-cluster scatter. Squared-distance sufficient statistics alone do not generally recover the mean Euclidean distance after a centroid moves; avoid advertising equivalence for operations that cannot preserve it.
Add targeted equivalence tests and update API documentation and benchmark labels so equivalent and non-equivalent DB comparisons are explicit.
Done when
Users can select an unambiguous Euclidean DB score that agrees with scikit-learn on supported inputs, and its operation support and cost are documented.
Closing as not planned under CVI's requirement that incremental indices retain compact summary statistics rather than historical samples.
sklearn.metrics.davies_bouldin_score uses mean Euclidean distance from each cluster's arithmetic centroid (q=1), divided by Euclidean centroid separation. When a new observation moves the centroid, all previous point-to-centroid distances change. For unrestricted inputs, this scatter cannot be maintained exactly using a fixed-size collection of ordinary numeric summary statistics.
For example, the one-dimensional clusters [-3, -3, 0, 0, 3, 3] and [-4, -1, -1, 1, 1, 4] have identical counts (6), centroids (0), squared compactness (36), and mean Euclidean scatter (2). Adding the same observation 7 moves both centroids to 1, but their mean Euclidean scatters become 20/7 and 18/7. Even retaining the old Euclidean scatter alongside our current statistics is insufficient.
More generally, F(t) = sum_i |x_i - t| has a slope change at every distinct historical value. A future observation can move the centroid to any t, so exact future scatter requires enough information to distinguish those functions, which encode the sample multiset. That information grows with the number of distinct observations in the worst case.
An exact batch-only implementation is feasible, as is an implementation that retains observations and revisits affected clusters. Neither meets the intended compact-state, interchangeable batch/incremental design. This is a limitation of the requested exact definition under that constraint, not a claim that batch DB is infeasible.
The original Davies-Bouldin paper also defines RMS scatter (q=2). That definition does fit CVI: retain squared compactness and use sqrt(CP_i / n_i) for scatter. Euclidean centroid separation gives the original p=q=2 case; other centroid Minkowski norms form the same q=2 family. These can share one new class with a centroid-distance parameter p defaulting to 2. Follow-up #141 covers both in one class, while preserving today's squared-distance DB behavior.
Activity
NiklasMelton commentedon Sep 30, 2026
Closing as not planned under CVI's requirement that incremental indices retain compact summary statistics rather than historical samples.
sklearn.metrics.davies_bouldin_scoreuses mean Euclidean distance from each cluster's arithmetic centroid (q=1), divided by Euclidean centroid separation. When a new observation moves the centroid, all previous point-to-centroid distances change. For unrestricted inputs, this scatter cannot be maintained exactly using a fixed-size collection of ordinary numeric summary statistics.For example, the one-dimensional clusters
[-3, -3, 0, 0, 3, 3]and[-4, -1, -1, 1, 1, 4]have identical counts (6), centroids (0), squared compactness (36), and mean Euclidean scatter (2). Adding the same observation7moves both centroids to 1, but their mean Euclidean scatters become20/7and18/7. Even retaining the old Euclidean scatter alongside our current statistics is insufficient.More generally,
F(t) = sum_i |x_i - t|has a slope change at every distinct historical value. A future observation can move the centroid to anyt, so exact future scatter requires enough information to distinguish those functions, which encode the sample multiset. That information grows with the number of distinct observations in the worst case.An exact batch-only implementation is feasible, as is an implementation that retains observations and revisits affected clusters. Neither meets the intended compact-state, interchangeable batch/incremental design. This is a limitation of the requested exact definition under that constraint, not a claim that batch DB is infeasible.
The original Davies-Bouldin paper also defines RMS scatter (
q=2). That definition does fit CVI: retain squared compactness and usesqrt(CP_i / n_i)for scatter. Euclidean centroid separation gives the originalp=q=2case; other centroid Minkowski norms form the sameq=2family. These can share one new class with a centroid-distance parameterpdefaulting to 2. Follow-up #141 covers both in one class, while preserving today's squared-distanceDBbehavior.References:
p=q=2DB because the square roots are absent.