Graph only partially displaying in Jupyter Noteboo

2019-06-24 03:53发布

问题:

I am trying to get a PyLDAvis graph that looks like the 2 shown in this link, that you can see right away (Intertopic Distance Map and Top 30 Most Salient Terms):

http://nbviewer.jupyter.org/github/bmabey/hacker_news_topic_modelling/blob/master/HN%20Topic%20Model%20Talk.ipynb

My code does display it but only partially, I can only see 1 cluster on the left and like 5-6 terms on the right, the rest gets cut off (there should be many clusters and 30 words shown). This is the code I have:

import warnings
warnings.filterwarnings('ignore')

import os 
%matplotlib inline
import pyLDAvis.gensim
import gensim
pyLDAvis.enable_notebook()

d = gensim.corpora.Dictionary.load('dictionary.dict')
c = gensim.corpora.MmCorpus('corpus.mm')


pd.options.display.max_colwidth = 5000
pd.options.display.show_dimensions
data = pyLDAvis.gensim.prepare(ldamodel, c, d, mds='tsne')

Any ideas as to why its only showing me part of the graph?

EDIT update:

It seems the very similar code below worked:

import warnings
warnings.filterwarnings('ignore')

ldamodel.save('topic.model')
import os 
%matplotlib inline
import pyLDAvis.gensim
import gensim
pyLDAvis.enable_notebook()

d = gensim.corpora.Dictionary.load('dictionary.dict')
c = gensim.corpora.MmCorpus('corpus.mm')
lda = gensim.models.LdaModel.load('topic.model')

pd.options.display.max_colwidth = 5000
data = pyLDAvis.gensim.prepare(lda, c, d, mds='tsne')
pyLDAvis.display(data)