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
KMeans ignores example weights in centroid updates and default initialization #7876
KMeans accepts an ExampleWeightColumnName, but appears to ignore weight magnitudes during the main training loop and the default K-means|| initialization.
Expected behavior
Centroids should be weighted means of their assigned examples:
centroid = sum(weight * features) / sum(weight)
Initialization should also account for example weights where appropriate.
Actual behavior
Source inspection shows:
Centroid updates accumulate unweighted feature vectors and divide by the number of assigned rows.
Default K-means|| initialization samples using distance-based weights without incorporating example weights. Its candidate-reduction step also counts rows rather than summing their weights.
Explicit K-means++ initialization does use example weights, but the subsequent training loop still computes unweighted centroids.
Consequently, a weight column can affect initialization differently depending on the selected algorithm, without producing weighted centroid updates.
Minimal repro
The following example isolates the centroid calculation by requesting one cluster:
Activity