Learn R Programming

bertopicr (version 0.3.6)

visualize_topics_per_class: Visualize Topics per Class

Description

This function visualizes the distribution of topics per class using a pre-trained BERTopic model. The visualization is generated using the Plotly Python package and displayed within an R environment.

Usage

visualize_topics_per_class(
  model = topic_model,
  topics_per_class = topics_per_class,
  start = 0,
  end = 10,
  filename = "topics_per_class",
  auto_open = TRUE
)

Value

A Plotly visualization of the topics per class, displayed as an HTML file within the R environment.

Arguments

model

A BERTopic model object. Default is 'topic_model'.

topics_per_class

A data frame or list containing the topics per class data. Default is 'topics_per_class'.

start

An integer specifying the starting index of the topics to visualize. Default is 0.

end

An integer specifying the ending index of the topics to visualize. Default is 10.

filename

A string specifying the name of the HTML file to save the visualization. Default is "topics_per_class".

auto_open

A logical value indicating whether to automatically open the HTML file after saving. Default is TRUE.

Examples

Run this code
# \donttest{
if (exists("topic_model") && exists("topics_per_class")) {
  visualize_topics_per_class(model = topic_model,
                             topics_per_class = topics_per_class,
                             start = 0, end = 7,
                             filename = "plot",
                             auto_open = TRUE)
} else {
  message("No topic_model/topics_per_class found. Train a model first.")
}
# }

Run the code above in your browser using DataLab