Github user rnowling commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2494#discussion_r17880653
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/feature/IDF.scala ---
    @@ -123,7 +134,17 @@ private object IDF {
           val inv = new Array[Double](n)
           var j = 0
           while (j < n) {
    -        inv(j) = math.log((m + 1.0)/ (df(j) + 1.0))
    +        /*
    +         * If the term is not present in the minimum
    +         * number of documents, set IDF to 0. This
    +         * will cause multiplication in IDFModel to
    +         * set TF-IDF to 0.
    +         */
    +        if(df(j) >= minimumOccurence) {
    +          inv(j) = math.log((m + 1.0)/ (df(j) + 1.0))
    +        } else {
    --- End diff --
    
    Yes, the branch is needed.  I don't modify the df vector -- I perform the 
filtering in idf().  I should probably have clarified the commit comments to 
explain that the IDF is set to 0, not the DF.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to