Skip to content

Scalable Kmeans++ also known as k-means|| #4357

Open

Description

@jagankr

I can see Kmeans++ implementation here but do you have scalable kmeans implementation which is supposed to be better than kmeans++

EDIT (reference):

Scalable K-Means++, Bahman Bahmani et al.
http://theory.stanford.edu/~sergei/papers/vldb12-kmpar.pdf

This algorithm is also known as "k-means||"

Activity

  1. GaelVaroquaux commented on Mar 7, 2015

    @GaelVaroquaux
    Member
  2. GaelVaroquaux commented on Mar 7, 2015

    @GaelVaroquaux
    Member
  3. changed the title [-]Scalable Kmeans[/-] [+]Scalable Kmeans++[/+] on Mar 7, 2015
  4. GaelVaroquaux commented on Mar 7, 2015

    @GaelVaroquaux
    Member

    This looks interesting: it is true that kmeans++ doesn't scale well to large datasets. We have found (in my group) that in the MiniBatchKMeans, work on the initialization was critical to get good results. Maybe this paper can improve things.

  5. jagankr commented on Mar 8, 2015

    @jagankr
    Author

    As I understand scalable kmeans can be implemented by modifying _k_init(). But i am not able figure out what needs to be changed. Can you plz give me some clue if you have any idea.
    Thanks in advance

  6. amueller commented on Mar 9, 2015

    @amueller
    Member

    I had the same issues @GaelVaroquaux. The paper doesn't seem widely cited but it is worth a try.
    Btw, I found that the init is often the most expensive part of KMeans and I could use KMeans instead of MiniBatchKMeans when I switched the init from kmeans++ to random.

  7. amueller commented on Mar 9, 2015

    @amueller
    Member

    @jagankr I haven't looked at the paper (yet) but you are more likely to get an answer with a more specific question. What is the issue you are having? Is the strategy not clear from the paper?

  8. amueller commented on Mar 9, 2015

    @amueller
    Member

    I'm not sure about the last step

    Recluster the weighted points in C into k clusters

    Does that mean running weighted K-Means?
    Then we'd need #4218 I think.

  9. jagankr commented on Mar 11, 2015

    @jagankr
    Author

    will you please give an application of kmeans clustering over a large dataset that enables us to compare the kmeans and kmeans++

  10. jagankr commented on Mar 11, 2015

    @jagankr
    Author

    compare means it should give a notable time difference.I think, it is possible only through an application that runs over a large dataset.

  11. 17 remaining items

  12. jovo commented on Mar 6, 2019

    @jovo

    @GaelVaroquaux
    @shrutim1
    we have this paper: https://arxiv.org/abs/1606.08905
    (published at Proceedings of the 26th International Symposium on High-Performance Parallel and Distributed Computing, 2017.)

    here is the C++ code: https://github.com/flashxio/knor
    and python bindings: https://github.com/flashxio/knorPy

    is that interesting/useful?

    we've never tried to make a PR to sklearn, but certainly open to it...

  13. GaelVaroquaux commented on Mar 6, 2019

    @GaelVaroquaux
    Member
  14. jovo commented on Mar 8, 2019

    @jovo

    hey @GaelVaroquaux , right, we have an more efficient implementation of the k-means++ algorithm, not a new algorithm, so i think based on this:

    A technique that provides a clear-cut improvement (e.g. an enhanced data structure or a more efficient approximation technique) on a widely-used method will also be considered for inclusion.

    our stuff gets the exact same answer as k-means++, just runs much faster.

    so, it seems like it would be ok?

  15. changed the title [-]Scalable Kmeans++[/-] [+]Scalable Kmeans++ also known as k-means||[/+] on May 29, 2020
  16. ogrisel commented on May 29, 2020

    @ogrisel
    Member

    @jovo sorry for the late reply. We are definitely interested in optimizing the implementation of existing methods. However our code base try to leverage the Python syntax as much as possible to make it readable by datascientists familiar with Python (our user-base).

    I would be interested in learning more on what are the main factor that make your implements faster

    Another very efficient C++ implementation of k-means++ and k-means|| (a.k.a. "scalable kmeans++") is available in Intel DAAL and daal4py:

    https://software.intel.com/sites/products/documentation/doclib/daal/daal-user-and-reference-guides/daal_cpp_api/group__kmeans__init.htm

    https://intelpython.github.io/daal4py/algorithms.html?highlight=kmeans#daal4py.kmeans_init

    Since DAAL implements both kmeans++ and kmeans||, benchmarking it might help us decide whether or not it's worth investing time in trying to implement kmeans|| in (wither with Python+numpy or Cython+BLAS) in scikit-learn.

    @jeremiedbb also experimented with a subsampled variant of kmeans++ that seems to give very good results.

  17. disa-mhembere commented on Aug 25, 2020

    @disa-mhembere

    @ogrisel, regarding the performance @jovo mentioned. The optimizations we implement significantly improve the performance of kmeans++ for multicore NUMA machines running the algorithm in parallel. No performance improvement is made when run serially or on single-core machines. We rely on NUMA memory allocation policies, and NUMA-sensitive dynamic task dispatching and NUMA-sensitive thread binding policies, among other optimizations. Optimizations performed are performed using low level C, but can be exposed to a python interface through bindings. We describe the framework we develop to support this here

  18. jovo commented on Aug 25, 2020

    @jovo

    @disa-mhembere I thought you also had a parallelized implementation of k-means++, which, at the time, was not otherwise implemented anywhere? And also some improvements to k-means algorithms via leveraging the triangle inequality more effectively than prior implementations?

  19. ogrisel commented on Dec 16, 2020

    @ogrisel
    Member

    I made a summary of our current understanding of the perf issues of k-means++ in this discussion #10924 (comment).

    Before considering k-means||, I would like to finalize the implementation improvement presented there and maybe the algorithmic improvement based on subsampling.

    All of them should be easy to maintain and lead >95% of the perf benefit of more complex method for >95% of our users.

  20. lorentzenchr commented on May 1, 2023

    @lorentzenchr
    Member

    After so many years, the papers have enough citation counts. But I don’t know if they already are superseded.
    @jeremiedbb @jjerphan @ogrisel What is your opinion? Close or set to „help wanted“?

  21. jjerphan commented on May 2, 2023

    @jjerphan
    Member

    I think that one of scikit-learn's goals is to keep its usage simple: to me, there's value in solely providing a few yet relevant and efficient implementations; hence I wonder whether a new initialization method would fulfill this goal.

    I am not against a new variant, but I think would consider accepting it if an implementation exists and has been shown to be competitive over scikit-learn's implementation of kmeans++ (hence I would label this present issue as "Help Wanted").

    What do other maintainers think?

  22. betatim commented on May 2, 2023

    @betatim
    Member
  23. GaelVaroquaux commented on May 10, 2023

    @GaelVaroquaux
    Member
  24. ogrisel commented on Sep 27, 2023

    @ogrisel
    Member

    Before implementing kmeans|| I think we should optimize our existing implementation of k-means++ using Cython and possibly prange/openmp as we already did a while ago for the subsequent main loop of Kmeans.fit.

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

    EnhancementLarge ScaleModeratePerformancehelp wantedmodule:cluster

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions