SciTech-BigDataAIML-Statistical Model-Topics Model主题模型-LDA(Latent Dirichilet Allocation, 潜在狄利克雷分布) Model

SciTech-BigDataAIML-Algorithm-Heuristic启发式-

Statistical Model(统计概率模型) 的一种
Topics Model(主题模型)

LDA(Latent Dirichilet Allocation) Topics Model主题模型。

LDA(Latent Dirichilet Allocation, 潜在狄利克雷分布)是一种 Topics Model(主题模型),
用于在Large Scale Docs(大量文档)自动发现Hidden Topics(隐藏主题)
在NLP和Text Analysis上, LDA被广泛应用于文本分类、文档聚类、信息检索等场景。

LDA的核心思想

Doc(每篇文档) 看作由 Topics(多个主题)构成,
Topic(每个主题)又由 Terms(一组单词)按一定Distribution(概率分布)生成.

from gensim import corpora,models
#假设已经有文本数据
texts=[ ["human","interface","computer"],
        ["survey","user","computer","system","response"] ]

#创建词典和语料库
dictionary=corpora.Dictionary(texts)
corpus=[dictionary.doc2bow(text) for text in texts]

#使用LDA进行主题分析
lda_model=models.LdaModel(corpus, num_topics=2, id2word=dictionary, passes=10)
topics=lda_model.print_topics(num_words=3)
for topic in topics:
    print(topic)


得到Output(输出)

[(0, '0.177*"computer" + 0.176*"user" + 0.176*"survey"'),
 (1, '0.230*"computer" + 0.228*"interface" + 0.228*"human"')]

posted @   abaelhe  阅读(21)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
历史上的今天:
2023-11-11 USB.org + USB 3.0 Type-C + PD(Power Delivery)240W
2023-11-11 BAW(Bulk Acoustic Wave) resonator with high Q-factor.
点击右上角即可分享
微信分享提示