Preparation
First, make sure you have the pyldavis and gensim libraries installed.
pip install gensim
pip install pyldavis
Code change
Secondly, if the error not attribute is because the version of pyldavis is different, the new version needs to be changed as follows: change all pyLDAvis.gensim to gensimvis。
import pyLDAvis.gensim as gensimvis
pyLDAvis.enable_notebook()
vis_sub_10 = gensimvis.prepare(lda_fst, corpus, dic, sort_topics = False)
vis_sub_20 = gensimvis.prepare(lda_snd, corpus, dic, sort_topics = False)
pyLDAvis.display(vis_sub_10)
Success! The effect is shown in the following figure.
Or you can install a lower version of pyldavis
pip install pyLDAvis==2.1.2
Codes:
import pyLDAvis.gensim
pyLDAvis.enable_notebook()
vis_sub_10 = pyLDAvis.gensimda_fst, corpus, dic, sort_topics = False)
vis_sub_20 = pyLDAvis.gensim.prepare(lda_snd, corpus, dic, sort_topics = False)
pyLDAvis.display(vis_sub_10)。
Read More:
- [Solved] Jupyter notebook use pyLDAvis Error: modulenotfounderror: no module named ‘pyLDAvis’‘
- [Solved] module ‘numpy.random‘ has no attribute ‘default_rng‘ gensim.model
- Gensim Error: AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0.
- [Solved] jupyter notebook Error: ModuleNotFoundError: No module named jupyter_nbextensions_configurator
- [Solved] AttributeError: module ‘setuptools._distutils‘ has no attribute ‘version‘
- [How to Solve]AttributeError: module ‘scipy’ has no attribute ‘io’
- Python AttributeError: module ‘tensorflow‘ has no attribute ‘InteractiveSession‘
- [Solved] AttributeError: module ‘distutils‘ has no attribute ‘version‘
- AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘ [How to Solve]
- [Solved] AttributeError: module ‘tensorflow‘ has no attribute ‘distributions‘
- AttributeError: module ‘time‘ has no attribute ‘clock‘ [How to Solve]
- [Solved] AttributeError: module ‘pandas‘ has no attribute ‘rolling_count‘
- [Perfectly Solved] attributeerror: module ‘SciPy. Misc’ has no attribute ‘toimage’ error
- [How to Solve]AttributeError: module ‘scipy’ has no attribute ‘stats’
- [Solved] AttributeError: module ‘logging‘ has no attribute ‘Handler‘
- [Solved] AttributeError: module ‘librosa.feature‘ has no attribute ‘inverse‘
- [Solved] AttributeError: module ‘PIL.Image‘ has no attribute ‘open‘
- [Solved] AttributeError: module ‘time‘ has no attribute ‘clock‘
- [Solved]AttributeError: module ‘urllib’ has no attribute ‘quote’
- [Solved] AttributeError: partially initialized module ‘xlwings’ has no attribute ‘App’