How to reproduce exact results with LDA function in R's topicmodels package

*爱你&永不变心* 提交于 2019-12-01 09:29:35

Not really an "answer" but there's no other way to post code snippets :-)

I gave the following a go:

library(topicmodels)

data(AssociatedPress)

lda1 <- LDA(AssociatedPress[1:20, ], control=list(seed=0), k=2)
lda2 <- LDA(AssociatedPress[1:20, ], control=list(seed=0), k=2)

identical(lda1, lda2)
[1] FALSE

all.equal(lda1, lda2)
[1] "Attributes: < Component 5: Attributes: < Component 10: 1 string mismatch > >"

a1 <- posterior(lda1, AssociatedPress)
a2 <- posterior(lda2, AssociatedPress)

identical(a1, a2)
[1] TRUE

all.equal(a1, a2)
[1] TRUE

all.equal(lda1@alpha,lda2@alpha)
[1] TRUE
all.equal(lda1@call,lda2@call)
[1] TRUE
all.equal(lda1@Dim,lda2@Dim)
[1] TRUE
all.equal(lda1@control,lda2@control)
[1] "Attributes: < Component 10: 1 string mismatch >"
all.equal(lda1@k,lda2@k)
[1] TRUE
all.equal(lda1@terms,lda2@terms)
[1] TRUE
all.equal(lda1@documents,lda2@documents)
[1] TRUE
all.equal(lda1@beta,lda2@beta)
[1] TRUE
all.equal(lda1@gamma,lda2@gamma)
[1] TRUE
all.equal(lda1@wordassignments,lda2@wordassignments)
[1] TRUE
all.equal(lda1@loglikelihood,lda2@loglikelihood)
[1] TRUE
all.equal(lda1@iter,lda2@iter)
[1] TRUE
all.equal(lda1@logLiks,lda2@logLiks)
[1] TRUE
all.equal(lda1@n,lda2@n)
[1] TRUE

identical(lda1@alpha,lda2@alpha)
[1] TRUE
identical(lda1@call,lda2@call)
[1] TRUE
identical(lda1@Dim,lda2@Dim)
[1] TRUE
identical(lda1@control,lda2@control)
[1] FALSE
identical(lda1@k,lda2@k)
[1] TRUE
identical(lda1@terms,lda2@terms)
[1] TRUE
identical(lda1@documents,lda2@documents)
[1] TRUE
identical(lda1@beta,lda2@beta)
[1] TRUE
identical(lda1@gamma,lda2@gamma)
[1] TRUE
identical(lda1@wordassignments,lda2@wordassignments)
[1] TRUE
identical(lda1@loglikelihood,lda2@loglikelihood)
[1] TRUE
identical(lda1@iter,lda2@iter)
[1] TRUE
identical(lda1@logLiks,lda2@logLiks)
[1] TRUE
identical(lda1@n,lda2@n)
[1] TRUE

Is the "unequal" @control significant?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!