Skip to content

[MRG] Fix empty clusters not correctly relocated#13486

Merged
NicolasHug merged 4 commits intoscikit-learn:masterfrom
jeremiedbb:fix-kmeans-relocate-empty-clusters
Apr 12, 2019
Merged

[MRG] Fix empty clusters not correctly relocated#13486
NicolasHug merged 4 commits intoscikit-learn:masterfrom
jeremiedbb:fix-kmeans-relocate-empty-clusters

Conversation

@jeremiedbb
Copy link
Copy Markdown
Member

@jeremiedbb jeremiedbb commented Mar 21, 2019

When using sample weights in KMeans, empty clusters are not correctly relocated.

basically what was done is

# for some i
new_center = X[i]  # should be multiplied by the weight
...
new_center /= sample_weight[i]

the added test fails on master

Copy link
Copy Markdown
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

assert estimator.n_iter_ == 1


def test_k_means_empty_cluster_relocated():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add ref to this PR maybe?

@jeremiedbb jeremiedbb force-pushed the fix-kmeans-relocate-empty-clusters branch from f031479 to cca9378 Compare April 12, 2019 12:16
@jeremiedbb
Copy link
Copy Markdown
Member Author

@NicolasHug I think this PR can be merged

- |API| The ``n_components_`` attribute in :class:`cluster.AgglomerativeClustering`
and :class:`cluster.FeatureAgglomeration` has been renamed to
``n_connected_components_``.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like there's a newline at the wrong place

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, merged master too quickly...

@NicolasHug NicolasHug merged commit e405505 into scikit-learn:master Apr 12, 2019
@NicolasHug
Copy link
Copy Markdown
Member

Thanks @jeremiedbb !

jeremiedbb added a commit to jeremiedbb/scikit-learn that referenced this pull request Apr 25, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants