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
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.
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
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.
@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?
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.
@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:
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.
@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
@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?
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.
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“?
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").
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++
I agree: if it demonstrate a compelling improvement, I'm in favor.
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.
Activity
GaelVaroquaux commentedon Mar 7, 2015
jagankr commentedon Mar 7, 2015
https://www.youtube.com/watch?v=cigXAxV3XcY
GaelVaroquaux commentedon Mar 7, 2015
jagankr commentedon Mar 7, 2015
http://theory.stanford.edu/~sergei/papers/vldb12-kmpar.pdf
[-]Scalable Kmeans[/-][+]Scalable Kmeans++[/+]GaelVaroquaux commentedon Mar 7, 2015
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.
jagankr commentedon Mar 8, 2015
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
amueller commentedon Mar 9, 2015
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.
amueller commentedon Mar 9, 2015
@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?
amueller commentedon Mar 9, 2015
I'm not sure about the last step
Does that mean running weighted K-Means?
Then we'd need #4218 I think.
jagankr commentedon Mar 11, 2015
will you please give an application of kmeans clustering over a large dataset that enables us to compare the kmeans and kmeans++
jagankr commentedon Mar 11, 2015
compare means it should give a notable time difference.I think, it is possible only through an application that runs over a large dataset.
17 remaining items
jovo commentedon Mar 6, 2019
@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...
GaelVaroquaux commentedon Mar 6, 2019
jovo commentedon Mar 8, 2019
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?
[-]Scalable Kmeans++[/-][+]Scalable Kmeans++ also known as k-means||[/+]ogrisel commentedon May 29, 2020
@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.
disa-mhembere commentedon Aug 25, 2020
@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
jovo commentedon Aug 25, 2020
@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?
ogrisel commentedon Dec 16, 2020
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.
lorentzenchr commentedon May 1, 2023
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“?
jjerphan commentedon May 2, 2023
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?
betatim commentedon May 2, 2023
I'd label it as "help wanted". CUML supports the "scalable kmeans++" init https://docs.rapids.ai/api/cuml/stable/api/#k-means-clustering
GaelVaroquaux commentedon May 10, 2023
ogrisel commentedon Sep 27, 2023
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.