powered by
Fits a Latent Dirichlet Allocation (LDA) model to a document-term matrix.
sm_train_lda( dtm, k = NULL, method = "gibbs", seed = 1729, iter = 500, burnin = 100, alpha = NULL, beta = 0.1 )
An LDA_Gibbs or LDA_VEM object from the topicmodels package.
A DocumentTermMatrix object.
Number of topics. If NULL, will attempt to use sm_select_optimal_k first. Default is NULL.
Method for fitting. Options: "gibbs" or "vem". Default is "gibbs".
Random seed for reproducibility. Default is 1729.
Number of Gibbs iterations (if method = "gibbs"). Default is 500.
Number of burn-in iterations (if method = "gibbs"). Default is 100.
Hyperparameter for document-topic distributions. Default is 50/k (following Griffiths & Steyvers 2004).
Hyperparameter for topic-word distributions. Default is 0.1.
if (FALSE) { # Requires document-term matrix from sm_create_dtm() dtm <- sm_create_dtm(processed_data) lda_model <- sm_train_lda(dtm, k = 10) }
Run the code above in your browser using DataLab