The function to create and train and an LDA model.
topicsModel(
dtm,
num_topics = 20,
num_top_words = 10,
num_iterations = 1000,
seed = 42,
save_dir = "./results",
load_dir = NULL
)
(R_obj) The document term matrix
(integer) The number of topics to be created
(integer) The number of top words to be displayed
(integer) The number of iterations to run the model
(integer) The seed to set for reproducibility
(string) The directory to save the model, if NULL, the model will not be saved
(string) The directory to load the model from, if NULL, the model will not be loaded
A list of the model, the top terms, the labels, the coherence, and the prevalence
# \donttest{
# Create LDA Topic Model
dtm <- topicsDtm(data = dep_wor_data$Depphrase)
#> [1] "The Dtm, data, and summary are saved in./results/seed_42/dtms.rds"
model <- topicsModel(dtm = dtm, # output of topicsDtm()
num_topics = 20,
num_top_words = 10,
num_iterations = 1000,
seed = 42,
save_dir = "./results")
#> [1] "The Model is saved in./results/seed_42/model.rds"
# Load precomputed LDA Topic Model
model <- topicsModel(load_dir = "./results",
seed = 42)
#> [1] "The Model is saved in./results/seed_42/model.rds"
# }