Visualize LDA Topics Using Word Clouds
This example shows how to visualize the words in Latent Dirichlet Allocation (LDA) model topics.
A latent Dirichlet allocation (LDA) model is a topic model which discovers underlying topics in a collection of documents and infers word probabilities in topics. You can visualize the LDA topics using word clouds by displaying words with their corresponding topic word probabilities.
Load LDA Model
Load the LDA model
factoryReportsLDAModel which is trained using a data set of factory reports detailing different failure events. For an example showing how to fit an LDA model to a collection of text data, see Analyze Text Data Using Topic Models.
load factoryReportsLDAModel mdl
mdl = ldaModel with properties: NumTopics: 7 WordConcentration: 1 TopicConcentration: 0.5755 CorpusTopicProbabilities: [0.1587 0.1573 0.1551 0.1534 0.1340 ... ] DocumentTopicProbabilities: [480x7 double] TopicWordProbabilities: [158x7 double] Vocabulary: ["item" "occasionally" "get" ... ] TopicOrder: 'initial-fit-probability' FitInfo: [1x1 struct]
Visualize Topics Using Word Clouds
Visualize the topics using the
numTopics = mdl.NumTopics; figure t = tiledlayout("flow"); title(t,"LDA Topics") for i = 1:numTopics nexttile wordcloud(mdl,i); title("Topic " + i) end