Aan de slagGa gratis aan de slag

Fitting an LDA

It's time to run your first topic model! As discussed, the three additional arguments of the LDA() function are critical for properly running a topic model. Note that running the LDA() function could take about 10 seconds. The tidyverse and tidytext packages along with the tidy_twitter dataset have been loaded for you.

Deze oefening maakt deel uit van de cursus

Introduction to Text Analysis in R

Cursus bekijken

Oefeninstructies

  • Load the topicmodels package.
  • Cast the word counts by tweet into a DTM.
  • Run an LDA with 2 topics and a Gibbs sampler.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Load the topicmodels package
___

# Cast the word counts by tweet into a DTM
dtm_twitter <- ___ %>% 
  ___(___) %>% 
  ___(___)

# Run an LDA with 2 topics and a Gibbs sampler
lda_out <- LDA(
  ___,
  k = ___,
  method = ___,
  control = list(seed = 42)
)
Code bewerken en uitvoeren