Learn R Programming

BERTopic (version 0.1.0)

bertopic_as_document_topic_matrix: Coerce to a document-topic probability matrix

Description

Extract the document-topic probabilities as a matrix. If probabilities were not computed during fitting, returns NULL (with a warning).

Usage

bertopic_as_document_topic_matrix(model, sparse = TRUE, prefix = TRUE)

Value

A matrix or sparse Matrix of size n_docs x n_topics, or NULL.

Arguments

model

A "bertopic_r" model object.

sparse

Logical; if TRUE and Matrix is available, returns a sparse matrix.

prefix

Logical; if TRUE, prefix columns as topic ids.