Let's start training the LDA model using the training corpus and keep track of the training time as follows:
val startTime = System.nanoTime()ldaModel = lda.run(corpus)val elapsed = (System.nanoTime() - startTime) / 1e9println("Finished training LDA model. Summary:")println("Training time: " + elapsed + " sec")
Now additionally, we can save the trained model for future reuse that can goes as follows:
//Saving the model for future useparams.ldaModel.save(spark.sparkContext, "model/LDATrainedModel")