Learn R Programming

textmineR (version 3.0.4)

predict.ctm_topic_model: Predict method for Correlated topic models (CTM)

Description

Obtains predictions of topics for new documents from a fitted CTM model

Usage

# S3 method for ctm_topic_model
predict(object, newdata, ...)

Arguments

object

a fitted object of class "ctm_topic_model"

newdata

a DTM or TCM of class dgCMatrix or a numeric vector

...

further arguments passed to or from other methods.

Value

a "theta" matrix with one row per document and one column per topic

Examples

Run this code
# NOT RUN {
# Load a pre-formatted dtm 
# }
# NOT RUN {
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,])
# }

Run the code above in your browser using DataLab