Given a document term matrix dtm
, text2vec
provides a nice integration with the LDAvis
package. However, I want to embed this visualisation into a markdown document. The LDAvis
package has methods such as createJSON
, which would allow me to do this, but these are all hidden inside a private method in textvec.
n_topics = 6
lda = LDA$new(n_topics = 6L, doc_topic_prior = 50 / n_topics, topic_word_prior = 1 / n_topics)
doc_topic_distr = lda$fit_transform(dtm, n_iter = 1000, convergence_tol = 1e-3, n_check_convergence = 10, progressbar = interactive())
Is there anyway to get back to the json of the visualisation, or otherwise access the private methods in text2vec::LDA$new
?
Yes, this is possible - provide corrsponding LDAvis arguments to plot
call. See example from official documentation https://github.com/dselivanov/text2vec/blob/master/docs/topic_modeling.Rmd#visualization