Skip to content

Commit 6149ca6

Browse files
committed
fix for setOptimizer
1 parent cf0007d commit 6149ca6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

mllib/src/main/scala/org/apache/spark/mllib/clustering/LDA.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,15 @@ class LDA private (
210210

211211
/**
212212
* Set the LDAOptimizer used to perform the actual calculation by algorithm name.
213-
* Currently "em" is supported.
213+
* Currently "em", "online" is supported.
214214
*/
215215
def setOptimizer(optimizerName: String): this.type = {
216216
this.ldaOptimizer =
217217
optimizerName.toLowerCase match {
218218
case "em" => new EMLDAOptimizer
219+
case "online" => new OnlineLDAOptimizer
219220
case other =>
220-
throw new IllegalArgumentException(s"Only em is supported but got $other.")
221+
throw new IllegalArgumentException(s"Only em, online are supported but got $other.")
221222
}
222223
this
223224
}

mllib/src/main/scala/org/apache/spark/mllib/clustering/LDAOptimizer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class OnlineLDAOptimizer extends LDAOptimizer {
396396
val batchResult = statsSum :* expElogbeta
397397

398398
// Note that this is an optimization to avoid batch.count
399-
update(batchResult, iteration, (miniBatchFraction * corpusSize).toInt)
399+
update(batchResult, iteration, (miniBatchFraction * corpusSize).ceil.toInt)
400400
this
401401
}
402402

0 commit comments

Comments
 (0)