Matrices terme-document

Introduction à l'analyse de texte en R

Maham Faisal Khan

Senior Data Science Content Developer

Matrices et parcimonie

sparse_review
    Terms
Docs admit ago albeit amazing angle awesome
   4     1   0      1       0     0       0
   5     0   1      0       1     1       0
   3     0   0      0       0     0       1
   2     0   0      0       0     0       0
Introduction à l'analyse de texte en R

Utiliser cast_dtm()

tidy_review %>% 
  count(word, id) %>% 
  cast_dtm(id, word, n)
<<DocumentTermMatrix (documents: 1791, terms: 9669)>>
Non-/sparse entries: 62766/17252622
Sparsity           : 100%
Maximal term length: NA
Weighting          : term frequency (tf)
Introduction à l'analyse de texte en R

Utiliser as.matrix()

dtm_review <- tidy_review %>% 
  count(word, id) %>% 
  cast_dtm(id, word, n) %>% 
  as.matrix()

dtm_review[1:4, 2000:2004]
      Terms
Docs   consecutive consensus consequences considerable considerably
  223            0         0            0            0            0
  615            0         0            0            0            0
  1069           0         0            0            0            0
  425            0         0            0            0            0
Introduction à l'analyse de texte en R

Passons à la pratique !

Introduction à l'analyse de texte en R

Preparing Video For Download...