spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiangrui Meng (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SPARK-14497) Use top instead of sortBy() to get top N frequent words as dict in ConutVectorizer
Date Sun, 10 Apr 2016 08:14:25 GMT

     [ https://issues.apache.org/jira/browse/SPARK-14497?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Xiangrui Meng updated SPARK-14497:
----------------------------------
    Assignee: Feng Wang

> 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
>            Assignee: Feng Wang
>             Fix For: 2.0.0
>
>
> 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


Mime
View raw message