1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Natural Language Processing in R

Exercise

LDA practice

You are interested in the common themes surrounding the character Napoleon in your favorite new book, Animal Farm. Napoleon is a Pig who convinces his fellow comrades to overthrow their human leaders. He also eventually becomes the new leader of Animal Farm.

You have extracted all of the sentences that mention Napoleon's name, pig_sentences, and created tokenized version of these sentences with stop words removed and stemming completed, pig_tokens. Complete LDA on these sentences and review the top words associated with some of the topics.

Instructions

100 XP
  • Perform LDA on pig_matrix while identifying 10 topics. Set a random seed of 1111 for reproducibility.
  • Extract the beta matrix from the results.
  • Filter the beta matrix to topic 2 only and arrange the values by decreasing beta values.
  • Filter the beta matrix to topic 3 only and arrange the values by decreasing beta values.