Visualizing the BERTopic model
I would like to call out a few functions that help to produce nice visual presentations:
.visualize_topics()
: Visualize topics.visualize_hierarchy()
: Visualize the hierarchy of topics.visualize_barchart()
: Visualize the words of a topic.visualize_heatmap()
: Visualize the similarity of topics
Let’s review each in detail.
Visualizing topics
BERTopic can visualize topics in a way very similar to pyLDAvis
and LDAvis
, as we have learned. To visualize the topics, run the following:
model.visualize_topics()
The Distance Map
in Figure 14.7 lets you use the slider at the bottom of the interactive map to select the topic. When you hover over a topic, it shows the size of the topic and its corresponding words:
Figure 14.7 – Intertopic distance map
Visualizing the hierarchy of topics
Because BERTopic uses HDBSCAN, it lets you visualize the hierarchical structure of the topics...