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

    https://github.com/apache/spark/pull/4047#discussion_r23724967
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAModel.scala ---
    @@ -0,0 +1,265 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.mllib.clustering
    +
    +import breeze.linalg.{DenseMatrix => BDM, normalize}
    +
    +import org.apache.spark.annotation.DeveloperApi
    +import org.apache.spark.mllib.linalg.{Vectors, Vector, Matrices, Matrix}
    +import org.apache.spark.rdd.RDD
    +import org.apache.spark.util.BoundedPriorityQueue
    +
    +/**
    + * :: DeveloperApi ::
    + *
    + * Latent Dirichlet Allocation (LDA) model.
    + *
    + * This abstraction permits for different underlying representations,
    + * including local and distributed data structures.
    + */
    +@DeveloperApi
    +abstract class LDAModel private[clustering] {
    +
    +  import LDA._
    +
    +  /** Number of topics */
    +  def k: Int
    +
    +  /** Vocabulary size (number of terms or terms in the vocabulary) */
    +  def vocabSize: Int
    +
    +  /**
    +   * Inferred topics, where each topic is represented by a distribution 
over terms.
    +   * This is a matrix of size vocabSize x k, where each column is a topic.
    +   * No guarantees are given about the ordering of the topics.
    +   */
    +  def topicsMatrix: Matrix
    +
    +  /**
    +   * Return the topics described by weighted terms.
    +   *
    +   * This limits the number of terms per topic.
    +   * This is approximate; it may not return exactly the top-weighted terms 
for each topic.
    +   * To get a more precise set of top terms, increase maxTermsPerTopic.
    +   *
    +   * @param maxTermsPerTopic  Maximum number of terms to collect for each 
topic.
    +   * @return  Array over topics, where each element is a set of top terms 
represented
    +   *          as (term weight in topic, term index).
    +   *          Each topic's terms are sorted in order of decreasing weight.
    +   */
    +  def describeTopics(maxTermsPerTopic: Int): Array[Array[(Double, String)]]
    --- End diff --
    
    Why `String` instead of an `Int`? It is not clear from the doc how the 
string is constructed. I'm thinking about using `Array[Vector]` as the return 
type and use sparse vectors to represent the distribution with thresholding. 
One minor downside is that the term indices are not ordered by term weights. 


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