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
)

Arguments

model

(list) The trained model

data

(tibble) The new data

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 predictions will not be saved

load_dir

(string) The directory to load the model from, if NULL, the predictions will not be loaded

Value

A tibble of the predictions

Examples

# \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"
# }