Visualize Documents in 3D Space using BERTopic
visualize_documents_3d.RdThis function generates a 3D visualization of documents using a pre-trained BERTopic model and UMAP dimensionality reduction. It uses Plotly for interactive visualizations and saves the output as an HTML file.
Usage
visualize_documents_3d(
model,
texts,
reduced_embeddings,
custom_labels = FALSE,
hide_annotation = TRUE,
tooltips = c("Topic", "Name", "Probability", "Text"),
filename = "visualize_documents_3d",
auto_open = FALSE
)Arguments
- model
A BERTopic model object. Default is 'topic_model'.
- texts
A character vector or list of cleaned text documents to visualize.
- reduced_embeddings
A matrix or data frame of reduced-dimensionality embeddings (3D). Typically generated using UMAP.
- custom_labels
Logical. If TRUE, custom topic labels are used. Default is FALSE.
- hide_annotation
Logical. If TRUE, hides annotations on the plot. Default is TRUE.
- tooltips
A character vector of tooltips for hover information. Default is c("Topic", "Name", "Probability", "Text").
- filename
A character string specifying the name of the HTML file to save the visualization. Default is "visualize_documents_3d". The
.htmlextension is automatically added if not provided.- auto_open
Logical. If TRUE, opens the HTML file in the browser after saving. Default is FALSE.