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

    https://github.com/apache/spark/pull/7064#discussion_r33568796
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAOptimizer.scala ---
    @@ -119,6 +120,14 @@ final class EMLDAOptimizer extends LDAOptimizer {
           }
         }
     
    +    // create term vertices for empty docs
    +    val emptyDocTermVertices: RDD[(VertexId, TopicCounts)] =
    +      docs.filter { case (_, termCounts: Vector) =>
    +        Vectors.norm(termCounts, p = 1.0) == 0.0 // empty docs has all 
zero termCounts
    +      }.mapValues { case(termCounts: Vector) =>
    --- End diff --
    
    This can just be `mapValues(termCounts => ...)`. Actually you don't need 
the type for the `termCounts` above either, or for `emptyDocTermVertices`, I 
think. That said, maybe don't change this unless you need to do another pass 
for another reason. And I suppose the code below does write some of this out 
too. So this seems OK to me as-is as well.



---
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