Github user hhbyyh commented on a diff in the pull request: https://github.com/apache/spark/pull/17461#discussion_r110827869 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/clustering/LDA.scala --- @@ -315,6 +315,27 @@ class LDA private ( this } + // Initial LDAModel can be provided rather than using random initialization + private var initialModel: Option[LDAModel] = None + + /** + * Set the initial starting point, bypassing the random initialization. + * This can be used for incremental learning. + * This is supported only for online optimizer, and the condition model.k == this.k must be met, + * failure results in an IllegalArgumentException. + */ + @Since("2.2.0") + def setInitialModel(model: LDAModel): this.type = { + require(model.k == k, "mismatched number of topics") + this.ldaOptimizer match { + case _: OnlineLDAOptimizer => + initialModel = Some(model) + this + case _ => throw new IllegalArgumentException( + "Only online optimizer supports initialization with a previous model.") + } + } --- End diff -- I'm thinking we should move all the parameter check into run, since user may set parameters in different orders.
--- 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