Step 7 - Topic modelling 

Print the top 10 topics, showing the top-weighted terms for each topic. Also, include the total weight in each topic as follows:

var sum = 0.0println(s"${params.k} topics:")topics.zipWithIndex.foreach {    case (topic, i) =>        println(s"TOPIC $i")        println("------------------------------")        topic.foreach {    case (term, weight) =>        term.replaceAll("\s", "")        println(s"$termt$weight")        sum = sum + weight    }println("----------------------------")println("weight: " + sum)println()

Now let's see the output of our LDA model towards topics modeling:

 5 topics: TOPIC 0 ------------------------------ come 0.0070183359426213635 make 0.006893251344696077 look 0.006629265338364568 know 0.006592594912464674 take 0.006074234442310174 little ...

Get Scala Machine Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.