Skip to content

Add a Euclidean Davies-Bouldin variant matching scikit-learn #137

Closed as not planned

Description

@NiklasMelton

Motivation

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.

Activity

  1. added
    enhancement
    on Sep 25, 2026
  2. NiklasMelton commented on Sep 30, 2026

    @NiklasMelton
    CollaboratorAuthor

    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.

    References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions