0

我正在使用topicmodelsR 中的包进行主题建模。我正在创建一个语料库对象,进行一些基本的预处理,然后创建一个 DocumentTermMatrix:

library(topicmodels)

#Set parameters for Gibbs sampling
burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,5,63,100001,765)
nstart <- 5
best <- TRUE

#Number of topics
k <- 8

#Run LDA using Gibbs sampling
# Start the clock!
ptm <- proc.time()
ldaOut <-LDA(dtm.new,k, method="Gibbs", control=list(nstart=nstart, seed = seed, best=best, 
                                                  burnin = burnin, iter = iter, thin=thin))
# Stop the clock
proc.time() - ptm

然后我在最后一行得到了错误

 #docs to topics

ldaOut.topics <- as.matrix(topics(ldaOut))

这是错误:

error in 1:nrow(counts) : argument of length 0

我认为这意味着它不能计算第一行。有什么方法可以检查。

4

1 回答 1

0

topic() 还没有给你一个矩阵吗?

无论如何,“长度为零的参数”告诉您对象“计数”的行数为零。

于 2017-12-29T21:14:44.577 回答