LDA是英文“Latent Dirichlet Allocation”的缩写,意思是隐含狄利克雷分布,是一种主题模型(topic model),它可以将文档集中每篇文档的主题以概率分布的形式给出。
gensim包中有LDA的一种实现。
本文介绍gensim包的安装过程。
(1)安装numpy
在命令行窗口输入命令“pip install numpy”。若已安装,则提示如下:
提示信息为:Requirement already satisfied: numpy in d:\programs\python\python310\lib\site-packages (1.23.2)
(2)安装scipy
在命令行窗口输入命令“pip install scipy”。若已安装,则提示如下:
提示信息为:
Requirement already satisfied: scipy in d:\programs\python\python310\lib\site-packages (1.9.0)
Requirement already satisfied: numpy<1.25.0,>=1.18.5 in d:\programs\python\python310\lib\site-packages (from scipy) (1.23.2)
(3)安装gensim
在命令行窗口输入命令“pip install gensim”,命令执行结果如下图所示:
(4)测试
在命令行窗口中,使用python命令启动python。
在python中测试,命令如下:
import numpy
import scipy
import gensim
结果如下图所示:
无异常提示信息,则说明gensim包已经安装成功了。
相关参考资料:
(1)LDA主题模型简介及Python实现.
http://www.kaotop.com/it/854371.html
(2)在python里安装gensim.
http://t.zoukankan.com/minfan-p-6420120.html