Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/5661#discussion_r29168959
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAOptimizer.scala ---
@@ -0,0 +1,210 @@
+/*
+ * 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 java.util.Random
+
+import breeze.linalg.{DenseVector => BDV, normalize}
+
+import org.apache.spark.annotation.Experimental
+import org.apache.spark.graphx._
+import org.apache.spark.graphx.impl.GraphImpl
+import org.apache.spark.mllib.impl.PeriodicGraphCheckpointer
+import org.apache.spark.mllib.linalg.Vector
+import org.apache.spark.rdd.RDD
+
+/**
+ * :: Experimental ::
+ *
+ * An LDAOptimizer specifies which optimization/learning/inference
algorithm to use, and it can
+ * hold optimizer-specific parameters for users to set.
+ */
+@Experimental
+trait LDAOptimizer{
+
+ /*
+ DEVELOPERS NOTE:
+
+ An LDAOptimizer contains an algorithm for LDA and performs the actual
computation, which
+ stores internal data structure (Graph or Matrix) and other parameters
for the algorithm.
+ The interface is isolated to improve the extensibility of LDA.
+ */
+
+ /**
+ * Initializer for the optimizer. LDA passes the common parameters to
the optimizer and
+ * the internal structure can be initialized properly.
+ */
+ private[clustering] def initialState(
+ docs: RDD[(Long, Vector)],
+ k: Int,
+ docConcentration: Double,
+ topicConcentration: Double,
+ randomSeed: Long,
+ checkpointInterval: Int): LDAOptimizer
+
+ private[clustering] def next(): LDAOptimizer
+
+ private[clustering] def getLDAModel(iterationTimes: Array[Double]):
LDAModel
+}
+
+/**
+ * :: Experimental ::
+ *
+ * Optimizer for EM algorithm which stores data + parameter graph, plus
algorithm parameters.
+ *
+ * Currently, the underlying implementation uses Expectation-Maximization
(EM), implemented
+ * according to the Asuncion et al. (2009) paper referenced below.
+ *
+ * References:
+ * - Original LDA paper (journal version):
+ * Blei, Ng, and Jordan. "Latent Dirichlet Allocation." JMLR, 2003.
+ * - This class implements their "smoothed" LDA model.
+ * - Paper which clearly explains several algorithms, including EM:
+ * Asuncion, Welling, Smyth, and Teh.
+ * "On Smoothing and Inference for Topic Models." UAI, 2009.
+ *
+ */
+@Experimental
+class EMLDAOptimizer extends LDAOptimizer{
--- End diff --
need space here too
---
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]