Description Usage Arguments Value See Also Examples
Convenience function allowing to plot
the evolution of the loss on the training / test set in order to inspect training convergence
the ETM
model in 2D dimensional space using a umap projection.
This plot uses function textplot_embedding_2d
from the textplot R package and
plots the top_n most emitted words of each topic and the topic centers in 2 dimensions
1 2 3 4 5 6 7 8 9 10 11 12 |
x |
an object of class |
type |
character string with the type of plot to generate: either 'loss' or 'topics' |
which |
an integer vector of topics to plot, used in case type = 'topics'. Defaults to all topics. See the example below. |
top_n |
passed on to |
title |
passed on to textplot_embedding_2d, used in case type = 'topics' |
subtitle |
passed on to textplot_embedding_2d, used in case type = 'topics' |
encircle |
passed on to textplot_embedding_2d, used in case type = 'topics' |
points |
passed on to textplot_embedding_2d, used in case type = 'topics' |
... |
arguments passed on to |
In case type
is set to 'topics', maps the topic centers and most emitted words for each topic
to 2D using summary.ETM
and returns a ggplot object by calling textplot_embedding_2d
.
For type 'loss', makes a base graphics plot and returns invisibly nothing.
ETM
, summary.ETM
, textplot_embedding_2d
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library(torch)
library(topicmodels.etm)
path <- system.file(package = "topicmodels.etm", "example", "example_etm.ckpt")
model <- torch_load(path)
plot(model, type = "loss")
library(torch)
library(topicmodels.etm)
library(textplot)
library(uwot)
library(ggrepel)
library(ggalt)
path <- system.file(package = "topicmodels.etm", "example", "example_etm.ckpt")
model <- torch_load(path)
plt <- plot(model, type = "topics", top_n = 7, which = c(1, 2, 14, 16, 18, 19),
metric = "cosine", n_neighbors = 15,
fast_sgd = FALSE, n_threads = 2, verbose = TRUE,
title = "ETM Topics example")
plt
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.