NLP04-pyLDAvis可视化主题
来源:互联网 发布:useragent windows nt 编辑:程序博客网 时间:2024/04/30 01:00
摘要:演示一个pyLDAvis例子,作为入门,结合gensim来进行文本主题分类提供可视化的入门。
1. 安装pyLDAvis
官网:http://pyldavis.readthedocs.io/en/latest/
安装:pip install pyLDAvis
这个安装如果网速不好,会比较慢,这里要安装比较多的依赖包。
2. 例子
这个例子的数据采用前面文章的,http://blog.csdn.net/ld326/article/details/78353338,这里只是重点突出一下主题模型的可视化。
import pyLDAvis.gensimfrom gensim import corporafrom gensim.models import LdaModeldef get_corpus_dictionary(): documents = ["Human machine interface for lab abc computer applications", "A survey of user opinion of computer system response time", "The EPS user interface management system", "System and human system engineering testing of EPS", "Relation of user perceived response time to error measurement", "The generation of random binary unordered trees", "The intersection graph of paths in trees", "Graph minors IV Widths of trees and well quasi ordering", "Graph minors A survey"] stoplist = set('for a of the and to in'.split()) texts = [[word for word in document.lower().split() if word not in stoplist] for document in documents] from collections import defaultdict frequency = defaultdict(int) for text in texts: for token in text: frequency[token] += 1 texts = [[token for token in text if frequency[token] > 1] for text in texts] dictionary = corpora.Dictionary(texts) corpus = [dictionary.doc2bow(text) for text in texts] return corpus, dictionarydef test_lda(): corpus, dictionary = get_corpus_dictionary() lda = LdaModel(corpus=corpus,num_topics=2) data = pyLDAvis.gensim.prepare(lda, corpus, dictionary) pyLDAvis.show(data,open_browser=False)if __name__ == "__main__": test_lda()
3. 结果显示
打开web浏览器,
输入:http://127.0.0.1:8888/
至于这个IP与端口是可以修改的,在pyLDAvis.show()方法中可以修改了。
点击显示的内容查看各主题情况:
【作者:happyprince, http://blog.csdn.net/ld326/article/details/78370495】
阅读全文
0 0
- NLP04-pyLDAvis可视化主题
- pyLDAvis基于gensim的LDA模型可视化
- 主题模型TopicModel:主题模型可视化
- 【主题可视化案例】系列一
- 【个人笔记重点,不作为参考】主题:数据可视化d3
- 用R做中文LDA主题模型可视化分析
- R语言︱LDA主题模型——最优主题数选取(topicmodels)+LDAvis可视化(lda+LDAvis)
- 可视化
- 可视化
- 可视化
- MFC界面库BCGControlBar v25.0新功能详解一:可视化主题
- 【2016 Esri全球用户大会主题看点】_可视化&分析APP—Insights for ArcGIS
- 主题
- 主题
- 主题
- 主题
- 主题
- 主题
- 混合云让英特尔和Google走到了一起
- 小米宣布进军越南市场,国际化步伐提速
- 践行“新人本主义” vivo进军一线市场
- 线性回归之特征归一化、步长选择、特征组合
- 应用中实现 3D Touch ios swift
- NLP04-pyLDAvis可视化主题
- Mybatis源码研究之BoundSql
- 【Java并发之】BlockingQueue
- linux shell之find常用命令
- 韩媒确认LG G6不会登陆中国,LG手机以后不在中国卖了?
- 俞永福宣布阿里大文娱初步整合结果,合一集团并入阿里影业
- 欢迎使用CSDN-markdown编辑器
- ECMAScript6语法使用
- 我的电路实践