I'm trying to create an interactive pyLDAvis visualization for an LDA model I have built, and although I am able to create a static visualization, I am struggling with the following:
- Outputting a dynamic visual that interacts with the 'relevance metric' slider on the top right hand corner of the screen. The words per topic, the saliency measures, etc. do not change when I adjust the relevance metric.
- After being unable to display an interactive visual through a saved html file and on a webpage, I tried to display the visual on Spyder. I tried using the following commands:
In: pyLDAvis.display(vis_data)
Out: <IPython.core.display.HTML object>
and
In: pyLDAvis.show(vis_data)
Out: FileNotFoundError: [Errno 2] No such file or directory: 'https://cdn.jsdelivr.net/gh/bmabey/pyLDAvis@3.3.1/pyLDAvis/js/ldavis.v1.0.0.css'
Below is the code that I have used to create the model and the plot. I'd appreciate it if I could get help in creating an interactive html file or in displaying the result in an IDE (preferably Spyder). My python version is 3.8.3. Thanks!
# Calling File Cleanser on a file
fileTextTokenized = FileCleanser(mahabharatatext)
# Converting each word into a word-count dictionary format
dictionary = Dictionary(fileTextTokenized)
dictionary.filter_extremes(no_below = 100, no_above = 0.8)
gensim_corpus = [dictionary.doc2bow(word) for word in fileTextTokenized]
temp = dictionary[0]
id2word = dictionary.id2token
# Setting model parameters
chunksize = 2000
passes = 20
iterations = 400
num_topics = 6
lda_model = LdaModel(
corpus=gensim_corpus,
id2word=id2word,
chunksize=chunksize,
alpha='auto',
eta='auto',
iterations=iterations,
num_topics=num_topics,
passes=passes
)
vis_data = gensimvis.prepare(lda_model, gensim_corpus, dictionary)
vis_data
pyLDAvis.display(vis_data)
pyLDAvis.save_html(vis_data, './FileModel'+ str(num_topics) +'.html')