我有点困惑,我想使用texthero库进行一些主成分分析(PCA)。但当我尝试运行我的代码时:
import texthero as heroimport pandas as pddf['pca']=(df['clean_tweet'].pipe(hero.clean).pipe(hero.do_tfidf).pipe(hero.do_pca))hero.scatterplot(df, col='pca', color='topic', title="PCA BBC Sport news")
我得到了以下错误:
ModuleNotFoundError: No module named 'gensim.sklearn_api
但当我输入!pip show gensim时,我得到了以下信息:
Name: gensimVersion: 4.0.1Summary: Python framework for fast Vector Space ModellingHome-page: http://radimrehurek.com/gensim
回答:
看起来“gensim.sklearn_api”模块在Gensim的4.0版本中被移除了。尝试降级Gensim的版本。
python -m pip install gensim==3.8.3
参考资料: https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4