This is a generic plotting utility (not specific to topic the model) for comparing “effects” across multiple dimensions (e.g., topics). The function has several options for selecting the features to compare.
annotation_heatmap(
effects_matrix,
select_features = c("largest", "distinctive", "both", "all"),
feature_sign = c("both", "positive", "negative"),
dims = colnames(effects_matrix),
compare_dims = colnames(effects_matrix),
n = 2,
show_dims = colnames(effects_matrix),
zero_value = 0.01,
font_size = 10,
verbose = TRUE
)A ggplot object.
n x d numeric matrix, where n is the number
of features and d is the number of dimensions. This could be for
example the word frequencies matrix F from a multinomial
topic model fitted using fit_topic_model. The row
and columns of this matrix must be named, otherwise this function
will throw and error.
This may be a character vector specifying
the features to plot (rows of the effects matrix). Or it may be one
of the following: "largest", which automatically selects the
largest effects for each chosen dimension; "distinctive",
which automatically selects the “most distinctive” effects
for each chosen dimension; or "both", which uses both
criteria to select features. Distinctive features are defined as
rows of the effects matrix that are much larger in magnitude than
the effects in the other dimensions that also share the same sign.
For automated selection of features, this
option determines whether to consider positive effects only
("positive"), negative effects only ("negative"), or
both ("both").
The dimensions (columns of the effect matrix) to consider for automatic feature selection. This should be dimension names (not numbers).
This should be dimension names (not numbers).
For automated feature selection, the number of features to
select of each type and for each dimension. (see arguments
select_features and feature_sign).
The dimensions (columns) to include in the plot. This should be dimension names (not numbers).
Numbers smaller than zero_value (in
magnitude) are not shown in the plot.
Specifies the font size for the plot.
When verbose = TRUE, the list of selected
features (rows) is printed.
data(newsgroups)
p1 <- annotation_heatmap(newsgroups$F,feature_sign = "positive")
Run the code above in your browser using DataLab