Introductie tot tekstanalyse in R
Maham Faisal Khan
Senior Data Science Content Developer
library(topicmodels)lda_out <- LDA( dtm_review, k = 2, method = "Gibbs", control = list(seed = 42) )
lda_out
Een LDA_Gibbs-topicmodel met 2 topics.
glimpse(lda_out)
Formele klasse 'LDA_Gibbs' [package "topicmodels"] met 16 slots
..@ seedwords : NULL
..@ z : int [1:75670] 1 2 2 1 1 2 1 1 2 2 ...
..@ alpha : num 25
..@ call : language LDA(x = dtm_review, k = 2, method = "Gibbs", ...
..@ Dim : int [1:2] 1791 9668
..@ control :Formal class 'LDA_Gibbscontrol' [package "topicmodels"] ...
..@ beta : num [1:2, 1:17964] -8.81 -10.14 -9.09 -8.43 -12.53 ...
...
lda_topics <- lda_out %>% tidy(matrix = "beta")lda_topics %>% arrange(desc(beta))
# A tibble: 19,336 x 3
topic term beta
<int> <chr> <dbl>
1 1 hair 0.0241
2 2 clean 0.0231
3 2 cleaning 0.0201
# … met nog 19,333 rijen
Introductie tot tekstanalyse in R