Here is the code for LDA topic modelling with R text2vec package:
library(text2vec)
tokens = docs$text %>% # docs$text: a colection of text documents
word_tokenizer
it = itoken(tokens, ids = docs$id, progressbar = FALSE)
v = create_vocabulary(it) %>%
prune_vocabulary(term_count_min = 10, doc_proportion_max = 0.2)
vectorizer = vocab_vectorizer(v)
dtm = create_dtm(it, vectorizer, type = "dgTMatrix")
lda_model = text2vec::LDA$new(n_topics = 10, doc_topic_prior = 0.1, topic_word_prior = 0.01)
doc_topic_distr = lda_model$fit_transform(x = dtm, n_iter = 1000,
convergence_tol = 0.001, n_check_convergence = 25,
progressbar = FALSE)
As far as I understand there are two sets of variables, named as public and private, please see the below image:
I am wondering how can I have access to private variable of "doc_len". I tried lda_model$doc_len and lda_model$private$doc_len, but they returned "NULL".
The reason I need is that the command "lda_model$plot()" plots LDAvis in R console, but I need to plot it in my own shiny app page. To do this, I want to extract all parameters for the following function as discussed in the below link: "https://github.com/cpsievert/LDAvis/issues/27".
I appreciate your response and help either for extracting private parameters of lda model or how to plot LDAvis with "lda_model$plot()" in own shiny app page.
Thanks, Sam