Skip to contents

Project ETM topic centers and their top associated words to a two-dimensional space using the backend UMAP summary path, then visualize the result with ggplot2.

Usage

plot_topic_embeddings(x, top_n = 15, ...)

Arguments

x

Either an nlp_topic_fit with engine = "topicmodels.etm" or a raw ETM object.

top_n

Integer. Number of top associated words to display per topic. Defaults to 15.

...

Additional arguments forwarded to summary(model, type = "umap", ...).

Value

A ggplot object.

Examples

if (FALSE) { # requireNamespace("topicmodels.etm", quietly = TRUE) && requireNamespace("torch", quietly = TRUE) && torch::torch_is_installed() && requireNamespace("uwot", quietly = TRUE)
path <- system.file(package = "topicmodels.etm", "example", "example_etm.ckpt")
model <- torch::torch_load(path)
plot_topic_embeddings(model, top_n = 5)
}