[jira] [Commented] (SPARK-4039) KMeans support sparse cluster centers
[ https://issues.apache.org/jira/browse/SPARK-4039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15146465#comment-15146465 ] yuhao yang commented on SPARK-4039: --- https://github.com/hhbyyh/spark/blob/kmeansSparse/mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeans.scala I got an implementation there that supports sparse k-means centers. The calculation pattern can be switched via an extra parameter and users can choose which pattern to use. As expected, it can save a lot of memory according to the average sparsity of the cluster centers, but will consume much more time also. For feature dimension of 10M and nonzero rate 1e-6, it can reduce memory consumption by 40 times yet used 700% time. Welcome to use if you really need to support large dimension k-means. > KMeans support sparse cluster centers > - > > Key: SPARK-4039 > URL: https://issues.apache.org/jira/browse/SPARK-4039 > Project: Spark > Issue Type: Improvement > Components: MLlib >Affects Versions: 1.1.0 >Reporter: Antoine Amend > Labels: clustering > > When the number of features is not known, it might be quite helpful to create > sparse vectors using HashingTF.transform. KMeans transforms centers vectors > to dense vectors > (https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeans.scala#L307), > therefore leading to OutOfMemory (even with small k). > Any way to keep vectors sparse ? -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-4039) KMeans support sparse cluster centers
[ https://issues.apache.org/jira/browse/SPARK-4039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14336177#comment-14336177 ] Derrick Burns commented on SPARK-4039: -- Support sparse data in the clusterer is a bad idea. But so is converting sparse data directly to a dense representation for any data of significant dimension. So, what do you do? The HashingTF is one approach to reduce the dimension of the data, but it is not a good one. Collisions can lead to dramatic overestimates. Instead, randoming indexing should be used. Randoming Indexing (http://en.wikipedia.org/wiki/Random_indexing), per the Johnson-Lindenstrauss Lemma, guarantees that the embedding in a lower dimension space preserves certain distance measures. See https://github.com/derrickburns/generalized-kmeans-clustering for an implementation. KMeans support sparse cluster centers - Key: SPARK-4039 URL: https://issues.apache.org/jira/browse/SPARK-4039 Project: Spark Issue Type: Improvement Components: MLlib Affects Versions: 1.1.0 Reporter: Antoine Amend Labels: clustering When the number of features is not known, it might be quite helpful to create sparse vectors using HashingTF.transform. KMeans transforms centers vectors to dense vectors (https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeans.scala#L307), therefore leading to OutOfMemory (even with small k). Any way to keep vectors sparse ? -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-4039) KMeans support sparse cluster centers
[ https://issues.apache.org/jira/browse/SPARK-4039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14333997#comment-14333997 ] Xiangrui Meng commented on SPARK-4039: -- I changed the JIRA title to be more descriptive of this issue. KMeans support sparse cluster centers - Key: SPARK-4039 URL: https://issues.apache.org/jira/browse/SPARK-4039 Project: Spark Issue Type: Improvement Components: MLlib Affects Versions: 1.1.0 Reporter: Antoine Amend When the number of features is not known, it might be quite helpful to create sparse vectors using HashingTF.transform. KMeans transforms centers vectors to dense vectors (https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/mllib/clustering/KMeans.scala#L307), therefore leading to OutOfMemory (even with small k). Any way to keep vectors sparse ? -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org