Learn R Programming

BERTopic (version 0.1.0)

bertopic_visualize_topics_per_class: Visualize topics per class

Description

Wrapper around Python BERTopic.visualize_topics_per_class(). This visualizes how topics are distributed across a set of classes, using the output of Python topics_per_class(docs, classes).

Usage

bertopic_visualize_topics_per_class(
  model,
  topics_per_class,
  top_n_topics = 10L,
  topics = NULL,
  normalize_frequency = FALSE,
  custom_labels = FALSE,
  title = NULL,
  width = NULL,
  height = NULL,
  file = NULL
)

Value

If file is NULL, an htmltools::HTML object. Otherwise, the normalized file path is returned invisibly.

Arguments

model

A "bertopic_r" model.

topics_per_class

A data frame or Python object as returned by BERTopic.topics_per_class(docs, classes).

top_n_topics

Integer; number of most frequent topics to display.

topics

Optional integer vector of topic IDs to include.

normalize_frequency

Logical; whether to normalize each topic's frequency within classes.

custom_labels

Logical or character scalar controlling label behavior (forwarded to Python).

title

Optional character plot title.

width, height

Optional integer figure width/height in pixels.

file

Optional HTML output path. If NULL, an htmltools::HTML object is returned.