R/topic_modeling_core.R
predict.ctm_topic_model.Rd
Obtains predictions of topics for new documents from a fitted CTM model
# S3 method for ctm_topic_model
predict(object, newdata, ...)
a fitted object of class "ctm_topic_model"
a DTM or TCM of class dgCMatrix or a numeric vector
further arguments passed to or from other methods.
a "theta" matrix with one row per document and one column per topic
Predictions for this method are performed using the "dot" method as described in the textmineR vignette "c_topic_modeling".
# Load a pre-formatted dtm
if (FALSE) {
data(nih_sample_dtm)
model <- FitCtmModel(dtm = nih_sample_dtm[1:20,], k = 3,
calc_coherence = FALSE, calc_r2 = FALSE)
# Get predictions on the next 50 documents
pred <- predict(model, nih_sample_dtm[21:100,])
}