Repository navigation
Description
Motivation
Follow-up to #137. Exact scikit-learn DB (q=1, mean Euclidean scatter) cannot meet CVI's compact-state incremental requirement for unrestricted inputs. The original Davies-Bouldin q=2 family can: its RMS scatter is recoverable from the sufficient statistics CVI already maintains.
Implement RMS DB and the wider q=2 family in one new class. RMS DB with Euclidean centroid separation is simply the p=2 default of that family, so separate classes or implementation issues are unnecessary.
Definition and public API
For cluster count
- Add a clearly named public class, e.g.
DBRMS(p=2, backend="numpy"), with factory registration and capability metadata. Final naming should identify the RMS scatter unambiguously. - Fix
q=2. Expose and validate finite realp >= 1; explicitly document whether the optionalp=inflimit is supported. Cover Manhattan (p=1), Euclidean (p=2), and a nonintegerpin tests. pchanges only the between-centroid Minkowski norm. Within-cluster scatter always remains Euclidean RMS, computed fromCP_i. Using squared Lp residuals within clusters for arbitrarypwould define a different metric and invalidate reuse of the current compactness recurrence.- Preserve existing
DBresults, defaults, and public behavior. Its mean-squared scatter / squared separation definition remains a distinct published relative. - Do not expose unsupported
q=1updates or describe the new class as numerically equivalent to scikit-learn DB.
Implementation scope
- Reuse the existing count, centroid, squared-compactness, and numerical residual state and the batch/incremental update formulas. Apply the RMS transformation only when deriving scatter for scoring.
- Retain no historical observations. State size should remain dependent on cluster count and feature dimension, not accumulated samples:
O(K*d + K^2)for the current dense pairwise layout. - Support initial batch evaluation, incremental initialization, and a batch followed by sample additions, under the existing
get_cvicontract. Repeated batch updates are not part of this issue. - Support removal, merging, and splitting through the existing compactness-based operations. Split input
compactnessremains the subset's sum of squared Euclidean deviations, not RMS scatter. - Update the affected centroid-distance row/column on additions and rebuild distances consistently after structural operations. Reuse Euclidean backend kernels for
p=2where appropriate and implement the other supported norms without changing existing indices' defaults. - Provide NumPy support. Clearly declare any additional backend support; do not advertise unsupported
p/backend combinations. JAX expansion is not required by this issue. - Specify undefined-state behavior consistently with CVI, including fewer than two clusters, coincident centroids, singleton clusters, and zero scatter. Scikit-learn-specific degeneracy shortcuts are not an equivalence target.
Validation and documentation
- Compare the result with an independent direct sample-based oracle for the stated formula, for every supported
pcategory. The oracle may retain samples in tests; the implementation must not. - Verify batch versus full-stream versus batch-then-stream equivalence within appropriate floating-point tolerances, including new/nonconsecutive labels.
- Verify remove, merge, and summary-based split results against fresh evaluation of the corresponding partition, and verify subsequent additions still agree.
- Include targeted degenerate and numerical cases, invalid
pvalues, and regression coverage preserving existing squaredDBbehavior. - Document the original
p=q=2definition, configurable centroid separation, operation/backend support, storage and update costs, and the distinction from both currentDBand scikit-learn'sq=1score. - Label any benchmark comparisons by definition; scikit-learn DB must not be presented as an equivalent oracle or equivalent implementation for this class. A broad benchmark campaign is not required here.
Done when
A single public q=2 DB class provides RMS DB at its p=2 default and the documented centroid Minkowski family, with exact mathematical batch/incremental/structural equivalence up to floating-point error, without retaining observations or changing existing DB behavior.
References
- Davies and Bouldin (1979), A Cluster Separation Measure, especially p. 225: the original dispersion exponent
qand centroid-distance exponentp. - Author-uploaded original paper.
- Moshtaghi et al., Online Cluster Validity Indices for Streaming Data, Section 5 / Eq. (5): the squared-distance relative and its incremental sufficient statistics.
Activity