You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2016/04/08 22:39:25 UTC
[jira] [Commented] (SPARK-14497) Use top instead of sortBy() to get
top N frequent words as dict in ConutVectorizer
[ https://issues.apache.org/jira/browse/SPARK-14497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15232881#comment-15232881 ]
Apache Spark commented on SPARK-14497:
--------------------------------------
User 'lionelfeng' has created a pull request for this issue:
https://github.com/apache/spark/pull/12265
> Use top instead of sortBy() to get top N frequent words as dict in ConutVectorizer
> ----------------------------------------------------------------------------------
>
> Key: SPARK-14497
> URL: https://issues.apache.org/jira/browse/SPARK-14497
> Project: Spark
> Issue Type: Improvement
> Components: ML
> Reporter: Feng Wang
>
> It's not necessary to sort the whole rdd to get top n frequent words.
> // Sort terms to select vocab
> wordCounts.sortBy(_._2, ascending = false).take(vocSize)
>
> we could use top() instead since:
> top - O ( n )
> sortBy - O (n*logn)
> A minor side effect introduced by top() using default implicit Ordering in Tuple2:
> if the terms with same TF in dictionary would be sorted in descending order.
> (a:1), (b:1),(c:1) => dict: [c, b, a]
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org