政策资讯

Policy Information


NLP之TM之LDA:利用LDA算法瞬时掌握文档的主题内容—利用希拉里邮件数据集训练LDA模型并对新文本进行主题分类

来源: 重庆市软件正版化服务中心    |    时间: 2022-09-19    |    浏览量: 51177    |   

NLP之TM之LDA:利用LDA算法瞬时掌握文档的主题内容—利用希拉里邮件数据集训练LDA模型并对新文本进行主题分类

目录

输出结果

设计思路

核心代码

训练数据集

LDA模型应用


输出结果


设计思路

核心代码

  1. lda = gensim.models.ldamodel.LdaModel(corpus=corpus, id2word=dictionary, num_topics=20)
  2. print('输出第10号分类:',lda.print_topic(10, topn=5))
  3. print('输出所有的主题分类:',lda.print_topics(num_topics=20, num_words=5))

 

训练数据集

下载链接:希拉里邮件数据集

LDA模型应用

使用训练好的LDA模型,输入以下几句话,判定各自属于哪个topic

Already voted? That's great! Now help Hillary win by signing up to make calls now
It's Election Day! Millions of Americans have cast their votes for Hillary—join them and confirm where you vote
We don’t want to shrink the vision of this country. We want to keep expanding it
We have a chance to elect a 45th president who will build on our progress, who will finish the job
 

评论

产品推荐

更多 >

QQ咨询 扫一扫加入群聊,了解更多平台咨询
微信咨询 扫一扫加入群聊,了解更多平台咨询
意见反馈
立即提交
QQ咨询
微信咨询
意见反馈