我有一个包含近 90 列和大约 200k 观察值的大数据集。其中一列包含描述,因此它只是文本。但是,我有 100 条不适用的描述。
我尝试了来自 GitHub 的 Pablo Barbera 关于主题模型的代码,因为我需要它。
输出
library(topicmodels)
library(quanteda)
des <- subset(finalMSI, !is.na(description), select=c(description))
corpus_des <- corpus(des$description)
df_des <- dfm(corpus_des, remove=stopwords("spanish"), verbose=TRUE,
remove_punct=TRUE, remove_numbers=TRUE)
cdes <- dfm_trim(df_des, min_docfreq = 2)
# estimate LDA with K topics
K <- 20
lda <- LDA(cdes, k = K, method = "Gibbs",
control = list(verbose=25L, seed = 123, burnin = 100, iter = 500))
LDA 中的错误(cdes, k = K, method = "Gibbs", control = list(verbose = 25L, : 输入矩阵的每一行都需要包含至少一个非零条目
因为我的子集中没有任何 NA,所以我不明白这个错误消息(这是我第一次使用这个包)