<jupyter_start><jupyter_text>Visualize the topics-keywordsWe will be using gensim for topic modelling visualization.Based on [Gensim Topic Modeling](https://www.machinelearningplus.com/nlp/topic-modeling-gensim-python/)<jupyter_code>import os
import sys
import gensim
import pyLDAvis
import pyLDAvis.gensim

from gensim import corpora
from gensim import models
from gensim.models.coherencemodel import CoherenceModel

print('Python Version: %s' % (sys.version))
dictionary = corpora.Dictionary.load('documents.dict')
corpus = corpora.MmCorpus('documents.mm')
lda_model = models.LdaModel.load('lda_model')
print(dictionary)
print(corpus)
print(lda_model)
import pickle
#with open('documents', 'wb') as f: #save
#    pickle.dump(mylist, f)

with open('documents', 'rb') as f: #load
    documents = pickle.load(f)<jupyter_output><empty_output><jupyter_text>Visualize the topics-keywordsNow that the LDA model is built, the next step is to examine the produced topics and the associated keywords. There is no better tool than pyLDAvis package’s interactive chart and is designed to work well with jupyter notebooks<jupyter_code># Visualize the topics
pyLDAvis.enable_notebook()
vis = pyLDAvis.gensim.prepare(lda_model, corpus, dictionary)
vis
pyLDAvis.save_html(vis, 'lDAvis.html')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09640397857689365, 'fraction_numerical': 0.0, 'mean_word_length': 6.832335329341317, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '134253', 'license': 'MIT', 'n_tokens_mistral': 443, 'n_tokens_neox': 427, 'n_words': 118, 'path': 'Notebooks/gensim-pyLDAvis.ipynb', 'repo_name': 'storopoli/topic-modelling', 'size': '1307'}