Tolka ämnen

Introduktion till textanalys i R

Maham Faisal Khan

Senior Data Science Content Developer

Två ämnen

lda_topics <- LDA(
  dtm_review,
  k = 2,
  method = "Gibbs",
  control = list(seed = 42)
) %>% 
  tidy(matrix = "beta")

word_probs <- lda_topics %>% group_by(topic) %>% slice_max(beta, n = 15) %>% ungroup() %>% mutate(term2 = fct_reorder(term, beta))
Introduktion till textanalys i R

Två ämnen

ggplot(
  word_probs, 
  aes(
    term2, 
    beta, 
    fill = as.factor(topic)
  )
) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~ topic, scales = "free") +
  coord_flip()

Introduktion till textanalys i R

Tre ämnen

lda_topics2 <- LDA(
  dtm_review,
  k = 3,
  method = "Gibbs",
  control = list(seed = 42)
) %>% 
  tidy(matrix = "beta")

word_probs2 <- lda_topics2 %>% group_by(topic) %>% slice_max(beta, n = 15) %>% ungroup() %>% mutate(term2 = fct_reorder(term, beta))
Introduktion till textanalys i R

Tre ämnen

ggplot(
  word_probs2, 
  aes(
    term2, 
    beta, 
    fill = as.factor(topic)
  )
) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~ topic, scales = "free") +
  coord_flip()

Introduktion till textanalys i R

Fyra ämnen

Introduktion till textanalys i R

Konsten att välja modell

  • Det är bra att lägga till ämnen som skiljer sig från varandra
  • Om ämnen börjar upprepas har vi gått för långt
  • Namnge ämnena utifrån kombinationen av ord med hög sannolikhet
Introduktion till textanalys i R

Nu kör vi en övning!

Introduktion till textanalys i R

Preparing Video For Download...