Get LDAvis json from text2vec

孤人 提交于 2021-01-01 13:33:11

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/51026117/get-ldavis-json-from-text2vec

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