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

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



a fitted object of class "lsa_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


# Load a pre-formatted dtm data(nih_sample_dtm) # Convert raw word counts to TF-IDF frequency weights idf <- log(nrow(nih_sample_dtm) / Matrix::colSums(nih_sample_dtm > 0)) dtm_tfidf <- Matrix::t(nih_sample_dtm) * idf dtm_tfidf <- Matrix::t(dtm_tfidf) # Fit an LSA model on the first 50 documents model <- FitLsaModel(dtm = dtm_tfidf[1:50,], k = 5) # Get predictions on the next 50 documents pred <- predict(model, dtm_tfidf[51:100,])