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

    https://github.com/apache/spark/pull/6791#discussion_r33828784
  
    --- Diff: python/pyspark/mllib/clustering.py ---
    @@ -562,5 +564,67 @@ def _test():
             exit(-1)
     
     
    +class LDAModel(JavaModelWrapper):
    +
    +    """ A clustering model derived from the LDA method.
    +
    +    Latent Dirichlet Allocation (LDA), a topic model designed for text 
documents.
    +    Terminology
    +    - "word" = "term": an element of the vocabulary
    +    - "token": instance of a term appearing in a document
    +    - "topic": multinomial distribution over words representing some 
concept
    +    References:
    +    - Original LDA paper (journal version):
    +    Blei, Ng, and Jordan.  "Latent Dirichlet Allocation."  JMLR, 2003.
    +
    +    >>> from pyspark.mllib.linalg import Vectors
    +    >>> from numpy.testing import assert_almost_equal
    +    >>> data = [
    +    ...     [1, Vectors.dense([0.0, 1.0])],
    +    ...     [2, SparseVector(2, {0: 1.0})],
    +    ... ]
    +    >>> rdd =  sc.parallelize(data)
    +    >>> model = LDA.train(rdd, k=2)
    +    >>> model.vocabSize()
    +    2
    +    >>> topics = model.topicsMatrix()
    +    >>> topics_expect = array([[0.5,  0.5], [0.5, 0.5]])
    +    >>> assert_almost_equal(topics, topics_expect, 1)
    +    """
    +
    +    def topicsMatrix(self):
    +        """Inferred topics, where each topic is represented by a 
distribution over terms."""
    +        return self.call("topicsMatrix").toArray()
    +
    +    def vocabSize(self):
    +        """Vocabulary size (number of terms or terms in the vocabulary)"""
    +        return self.call("vocabSize")
    +
    +
    +class LDA():
    +
    +    @classmethod
    +    def train(cls, rdd, k=10, maxIterations=20, docConcentration=-1.0,
    +              topicConcentration=-1.0, seed=None, checkpointInterval=10, 
optimizer="em"):
    +        """Train a LDA model.
    +
    +        :param rdd:                 RDD of data points
    +        :param k:                   Number of clusters you want
    +        :param maxIterations:       Number of iterations. Default to 20
    +        :param docConcentration:    Concentration parameter (commonly 
named "alpha")
    +            for the prior placed on documents' distributions over topics 
("theta").
    +        :param topicConcentration:  Concentration parameter (commonly 
named "beta" or "eta")
    +            for the prior placed on topics' distributions over terms.
    +        :param seed:                Random Seed
    +        :param checkpointInterval:  Period (in iterations) between 
checkpoints.
    +        :param optimizer:           LDAOptimizer used to perform the 
actual calculation
    +            (default = EMLDAOptimizer)
    --- End diff --
    
    Sorry, I should have noticed this earlier: This should say "em" since that 
is the actual value specified.  Can it also say the 2 supported values (em and 
online)?


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