【问题标题】:Convert from dfm to dtm从 dfm 转换为 dtm
【发布时间】:2021-04-18 03:26:48
【问题描述】:

我尝试使用 [此处][1] 报告的一致性度量计算。

我使用 quanteda,所以我有一个 dfm

但是在链接中使用 dtm: #创建 DTM

dtm <- CreateDtm(tokens$text, 
                 doc_names = tokens$ID, 
                 ngram_window = c(1, 2))
#explore the basic frequency
tf <- TermDocFreq(dtm = dtm)
original_tf <- tf %>% select(term, term_freq,doc_freq)
rownames(original_tf) <- 1:nrow(original_tf)
# Eliminate words appearing less than 2 times or in more than half of the
# documents
vocabulary <- tf$term[ tf$term_freq > 1 & tf$doc_freq < nrow(dtm) / 2 ]
dtm = dtm

如何在这个计算中使用 dfm 而不是 dtm 的选项

更具体地说,如何使用 dfm 和 dtm 选项创建词汇表? [1]:https://towardsdatascience.com/beginners-guide-to-lda-topic-modelling-with-r-e57a5a8e7a25

【问题讨论】:

    标签: r quanteda


    【解决方案1】:

    你想要convert()。例如

    convert(yourdfm, to = "topicmodels")
    

    convert(yourdfm, to = "tm")
    

    ?convert

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      • 2020-11-25
      • 2017-10-16
      • 1970-01-01
      • 1970-01-01
      • 2022-07-15
      • 2011-11-12
      相关资源
      最近更新 更多