楼主: |Devil灬
2462 7

[问答] 主题模型建立时候出现错误 [推广有奖]

  • 0关注
  • 1粉丝

初中生

57%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
82 点
帖子
8
精华
0
在线时间
16 小时
注册时间
2015-5-9
最后登录
2016-4-9

楼主
|Devil灬 发表于 2015-8-28 23:49:17 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
result <- slda.em(documents=corpus$documents,
                  K=num.topics,
                  vocab=corpus$vocab,
                  num.e.iterations=30,
                  num.m.iterations=12,
                  alpha=1.0, eta=0.1,
                  poliblog.ratings / 100,
                  params,
                  variance=0.25,
                  lambda=1.0,
                  logistic=FALSE,
                  method="sLDA")
这个是代码,出现:Error in slda.em(documents = corpus$documents, K = num.topics, vocab = corpus$vocab,  :
  All documents must have positive length.
求大神教下如何解决

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:主题模型 Result RESUL RES documents result 主题 模型

沙发
asdasdaseee 发表于 2015-8-29 03:05:15
这个没用过,看了下注释:
documents       
A list whose length is equal to the number of documents, D. Each element of documents is an integer matrix with two rows. Each column of documents[[i]] (i.e., document i) represents a word occurring in the document.
documents[[i]][1, j] is a 0-indexed word identifier for the jth word in document i. That is, this should be an index - 1 into vocab. documents[[i]][2, j] is an integer specifying the number of times that word appears in the document.

vocab       
A character vector specifying the vocabulary words associated with the word indices used in documents.

感觉是不是documents错了。

藤椅
|Devil灬 发表于 2015-8-29 08:41:45
asdasdaseee 发表于 2015-8-29 03:05
这个没用过,看了下注释:
documents       
A list whose length is equal to the number of documents, D. Ea ...
你用的不是lda建立模型吗

板凳
更静一点 发表于 2016-4-22 01:29:19
请问一下,这个问题有解决吗,我也遇到同样的问题
> result <- slda.em(documents=corpus$documents,
+                   K=num.topics,
+                   vocab=corpus$vocab,
+                   num.e.iterations=30,
+                   num.m.iterations=12,
+                   alpha=1.0, eta=0.1,
+                   poliblog.ratings / 100,
+                   params,
+                   variance=0.25,
+                   lambda=1.0,
+                   logistic=FALSE,
+                   method="sLDA")
Error in slda.em(documents = corpus$documents, K = num.topics, vocab = corpus$vocab,  :
  All documents must have positive length.

报纸
fsgaojie 发表于 2016-9-6 11:25:25
corpus$documents和 poliblog.ratings 的length要一样

地板
Lzj、 发表于 2016-12-8 19:58:30
更静一点 发表于 2016-4-22 01:29
请问一下,这个问题有解决吗,我也遇到同样的问题
> result
您好,我也遇到了相关问题,不知您是否解决了,可以借鉴一下吗?

7
金玉满唐 发表于 2017-8-28 15:07:52
slda.em函数中关于此处错误的代码如下
if (min(sapply(documents, length)) <= 0) {
        stop("All documents must have positive length.")

所以问题出在min(sapply(documents, length)) <= 0
换成人话就是documents中存在空值。
slda.em之前清洗一下就好了,楼上说的问题也需要注意

corpus$documents和 poliblog.ratings 的length要一样

8
501921505 发表于 2018-9-15 20:21:01
金玉满唐 发表于 2017-8-28 15:07
slda.em函数中关于此处错误的代码如下
if (min(sapply(documents, length))
请问一下应该怎么清洗啊

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 22:44