topicsModel {topics} | R Documentation |
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,
load_dir = NULL
)
dtm |
(R_obj) The document term matrix |
num_topics |
(integer) The number of topics to be created |
num_top_words |
(integer) The number of top words to be displayed |
num_iterations |
(integer) The number of iterations to run the model |
seed |
(integer) The seed to set for reproducibility |
save_dir |
(string) The directory to save the model, if NULL, the model will not be saved |
load_dir |
(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
# Create LDA Topic Model
save_dir_temp <- tempfile()
dtm <- topicsDtm(
data = dep_wor_data$Depphrase,
save_dir = save_dir_temp)
model <- topicsModel(
dtm = dtm, # output of topicsDtm()
num_topics = 20,
num_top_words = 10,
num_iterations = 1000,
seed = 42,
save_dir = save_dir_temp)
# Load precomputed LDA Topic Model
model <- topicsModel(
load_dir = save_dir_temp,
seed = 42,
save_dir = save_dir_temp)