参考链接: https://www.codenong.com/60246570/

报错原因:D:\software\Anaconda\envs\LDA\lib\site-packages\gensim\topic_coherence\direct_confirmation_measure.py:204: RuntimeWarning: divide by zero encountered in double_scalars
m_lr_i = np.log(numerator / denominator)
D:\software\Anaconda\envs\LDA\lib\site-packages\gensim\topic_coherence\indirect_confirmation_measure.py:323: RuntimeWarning: invalid value encountered in double_scalars
return cv1.T.dot(cv2)[0, 0] / (_magnitude(cv1) * _magnitude(cv2))
nan

数据准备

     dataAll, data = data_dispose.loaddata()# print(dataAll.content_cutted)train = []for line in dataAll.content_cutted:line = [word.strip() for word in line.split(' ')]train.append(line)print(type(train))# exit()dictionary = corpora.Dictionary(train)corpus = [dictionary.doc2bow(test) for test in train]

修改前

    def coherence(num_topics):lda = models.LdaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics, passes=60, alpha=5, eta=0.01,random_state=1)print(lda.print_topics(num_topics=num_topics, num_words=10))ldacm = models.CoherenceModel(model=lda, texts=corpus, dictionary=dictionary, coherence='c_v')print(ldacm.get_coherence())return ldacm.get_coherence()

修改完(将CoherenceModel函数中的texts参数值从corpus修改为train)

    def coherence(num_topics):lda = models.LdaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics, passes=60, alpha=5, eta=0.01,random_state=1)print(lda.print_topics(num_topics=num_topics, num_words=10))ldacm = models.CoherenceModel(model=lda, texts=train, dictionary=dictionary, coherence='c_v')print(ldacm.get_coherence())return ldacm.get_coherence()

错误原因:一致性模型需要原始文本,而不是输入到LDA_Model的训练语料库

LDA主题模型中coherence(一致性)报错得出来为nan解决办法相关推荐

  1. 计算机开机故障报错,笔记本电脑开机报错故障的原因及解决办法

    笔记本电脑开机报错故障是指笔记本电脑开机自检时或启动操作系统前停止启动,在显示屏 出现一些错误提示的故障. 笔记本电脑开机报错故障的原因及解决办法 造成此类故障的原因一般是笔记本电脑在启动自检时,检测 ...

  2. 微信老是不能登录服务器错误,微信登录失败报错“4-100”的原因及解决办法

    微信登录失败报错"4-100"怎么办?微信是目前为止大家最喜欢的社交软件了,如果微信登录不了,整个人都不好了.最近就有用户遇到手机微信登录不了的情况,错误代码为"4-10 ...

  3. oracle pls 00905,【案例】Oracle报错PLS-00714 PLS-00951原因和解决办法笔记

    [案例]Oracle报错PLS-00714 PLS-00951原因和解决办法笔记 时间:2016-11-14 11:07   来源:Oracle研究中心   作者:代某人   点击: 次 天萃荷净 P ...

  4. Mac 升级后git pull 报错fatal: Authentication failed for 解决办法

    转载:Mac 升级后git pl 报错fatal: Authentication failed for 解决办法 - 简书 git pull,,,报错如下: cat .git/config git r ...

  5. 0x80070422报错、0x6D9报错,无法开启防火墙解决办法(方法版)

    0x80070422报错.0x6D9报错,无法开启防火墙解决办法 一.现象 现象1-报错0x80070422 现象2-报错0x6D9 二.解决方法 1.打开服务 2.打开防火墙服务 一.现象 现象1- ...

  6. Keras模型中数据维度报错

    ValueError: Input 0 of layer dense is incompatible with the layer: expected axis -1 of input shape 使 ...

  7. VirtualBox运行中经常报错0x00000000不能为written解决办法(附上所需文件下载链接)

    废话先不说,首先附上三个dll改好backup+破解恢复工具UniversalThemePatcher.exe的下载链接 https://pan.baidu.com/s/1OJD0j1ge20cHqS ...

  8. RT-Thread Studio中ST-LINK下载报错“Old ST-LINK firmware version“解决

    1.问题 RT-Thread Studio中选择ST-LINK下载,报错如下: 2.分析及解决步骤 这个报错是说ST-LINK的版本太老了,请升级. 首先报错没说找不到ST-LINK驱动啥的,只是说版 ...

  9. video.js在vue项目中设置中文语言包,报错videojs is not defined 解决办法

    在vue项目中使用video.js时要求中文化,但是网上的解决办法不太好找,特此记录一下. 错误步骤: 根据网上的教程,找到中文包在node_modules/video.js/dist/lang/zh ...

最新文章

  1. spring中那些让你爱不释手的代码技巧
  2. Google 公司的 Java 语言编写规范
  3. 关于listen的第二个参数backlog的一些问答见解
  4. 《数据库系统实训》实验报告——函数的应用
  5. 桥接模式coding
  6. 应用内购买(IAP)各类型在服务端的验证规则
  7. Wireshark抓包工具使用
  8. linux下创建用户,给用户设置密码,给用户授权
  9. 微信公众平台开发(77) 图片下载
  10. OpenWrt常用命令总结
  11. 【数论思维题】Enlarge GCD【Codeforces Round #511 (Div. 2)】
  12. 海思平台35xx系列sensor不出图问题排查方法(新手来看)
  13. VScode中文注释乱码问题解决
  14. jQuery--表单校验
  15. SEO人员:如何预估SEO投资回报率?
  16. 【已解决】maven打包时xxx.xxx程序包不存在
  17. 【测评】国外AR平台ENTITI测评-网页编辑器(1)
  18. python if else 嵌套格式_python中if嵌套命令实例讲解
  19. jdk1.8新特性:stream流报错:stream has already been operated upon or closed
  20. 2017中兴算法挑战赛(迪杰斯特拉)

热门文章

  1. 卿学姐种花(线段树)
  2. ActiveX 控件开发学习笔记1
  3. 阿里云服务器 Ubuntu安装Redis
  4. SufaceView播放视频 进入后台重新进入不会播放
  5. kafka消费者参数详解 java读取不到消费者数据
  6. python高校学生消费行为分析系统
  7. 方法executeQuery
  8. java注解教程 pdf_Java注解教程和自定义注解
  9. 光眼图和电眼图_光通信中的眼图是什么意思
  10. iphone九宫格的界面