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

    https://github.com/apache/spark/pull/4807#discussion_r26188892
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/LDA.scala 
---
    @@ -311,165 +319,319 @@ private[clustering] object LDA {
     
       private[clustering] type TokenCount = Double
     
    -  /** Term vertex IDs are {-1, -2, ..., -vocabSize} */
    -  private[clustering] def term2index(term: Int): Long = -(1 + term.toLong)
     
    -  private[clustering] def index2term(termIndex: Long): Int = -(1 + 
termIndex).toInt
     
    -  private[clustering] def isDocumentVertex(v: (VertexId, _)): Boolean = 
v._1 >= 0
    +  object LearningAlgorithms extends Enumeration {
    +    type Algorithm = Value
    +    val Gibbs, EM = Value
    +  }
     
    -  private[clustering] def isTermVertex(v: (VertexId, _)): Boolean = v._1 < 0
    +  private[clustering] trait LearningState {
    +    def next(): LearningState
    +    def topicsMatrix: Matrix
    +    def describeTopics(maxTermsPerTopic: Int): Array[(Array[Int], 
Array[Double])]
    --- End diff --
    
    The reason for a separate method is twofold. First, although you could 
calculate it from `topicsMatrix` in theory, the size of `topicsMatrix` could be 
very large (too large to fit in the driver memory, as the docs warn). The 
describeTopics is intended to provide an interface for the implementation to 
extract a topics matrix bounded to only the top `maxTermsPerTopic` topics. It 
is less likely this runs the driver out of memory and keeps computation of the 
top `n` topics distributed.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to