Learn R Programming

BERTopic (version 0.1.0)

bertopic_fit: Fit BERTopic from R

Description

A high-level wrapper around Python 'BERTopic'. Python dependencies are checked at runtime.

Usage

bertopic_fit(text, embeddings = NULL, ...)

Value

An S3 object of class "bertopic_r" containing:

  • .py: the underlying Python model (reticulate object)

  • topics: integer vector of topic assignments

  • probs: numeric matrix/data frame of topic probabilities (if available)

Arguments

text

Character vector of documents.

embeddings

Optional numeric matrix (n_docs x dim). If supplied, passed through to Python.

...

Additional arguments forwarded to bertopic.BERTopic(...).

Examples

Run this code
if (FALSE) {
if (reticulate::py_module_available("bertopic")) {
  m <- bertopic_fit(c("a doc", "another doc"))
  print(class(m))
}
}

Run the code above in your browser using DataLab