Perplexity calculation unavailable
seonghobae opened this issue · 1 comments
seonghobae commented
Hello,
I can not get any perplexity calculation values from DTM object of udpipe library.
Could you check this issues as soon as possible?
library('udpipe')
library('topicmodels')
burnin = 1000
iter = 1000
keep = 50
fitted <- topicmodels::LDA(dtm_clean, k = 2, method = "Gibbs",
control = list(burnin = burnin, iter = iter, keep = keep) )
perplexity(fitted, dtm_clean)
> perplexity(fitted, dtm_clean)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘perplexity’ for signature ‘"LDA_Gibbs", "dgCMatrix"’
Best,
Seongho
jwijffels commented
udpipe does not provide a function called perplexity. That's a function from the topicmodels package. That package works with the slam package, so you need to use that. As in
library(slam)
perplexity(mymodel, newdata = as.simple_triplet_matrix(dtm_clean))