Exécuter des modèles thématiques

Introduction à l'analyse de texte en R

Maham Faisal Khan

Senior Data Science Content Developer

Utiliser LDA()

library(topicmodels)

lda_out <- LDA( dtm_review, k = 2, method = "Gibbs", control = list(seed = 42) )
Introduction à l'analyse de texte en R

Sortie de LDA()

lda_out
Un modèle thématique LDA_Gibbs avec 2 thèmes.
Introduction à l'analyse de texte en R

Utiliser glimpse()

glimpse(lda_out)
Classe formelle « LDA_Gibbs » [package "topicmodels"] avec 16 emplacements
  ..@ 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        :Classe formelle « LDA_Gibbscontrol » [package "topicmodels"] ...
  ..@ beta           : num [1:2, 1:17964] -8.81 -10.14 -9.09 -8.43 -12.53 ...
  ...
Introduction à l'analyse de texte en R

Utiliser tidy()

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
# … avec 19 333 lignes de plus
Introduction à l'analyse de texte en R

Passons à la pratique !

Introduction à l'analyse de texte en R

Preparing Video For Download...