bnosac/udpipe

Perplexity calculation unavailable

seonghobae opened this issue · 1 comments

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 functionperplexityfor signature"LDA_Gibbs", "dgCMatrix"

Best,
Seongho

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))