The function to predict the topics of a new document with the trained model.
topicsPreds(
model,
data,
num_iterations = 100,
seed = 42,
save_dir = "./results",
load_dir = NULL
)
(list) The trained model
(tibble) The new data
(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 predictions will not be saved
(string) The directory to load the model from, if NULL, the predictions will not be loaded
A tibble of the predictions
# \donttest{
# Predict topics for new data with the trained 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"
preds <- topicsPreds(model = model, # output of topicsModel()
data = dep_wor_data$Depphrase)
#> [1] "Predictions are saved in./results/seed_42/preds.rds"
# }