【发布时间】:2017-06-22 17:39:25
【问题描述】:
我想从文章中提取主题,测试文章是“https://julien.danjou.info/blog/2017/announcing-scaling-python”。
这是一篇关于 python 和缩放的文章。我试过 lsi 和 lda,大部分时间, lda 似乎效果更好。但是两者的输出都不稳定。
当然,前三五个关键词似乎中了目标。 "python", "book", 'project' (我不认为 'project' 应该是一个有用的主题,并且会将它放在停用词列表中。),缩放或可扩展或 openstack 应该在关键字列表中,但不稳定全部。
主题列表和停用词列表可能会改善结果,但它不可扩展。我必须为不同的域维护不同的列表。
那么这里的问题是,有没有更好的方案来改进算法?
num_topics = 1
num_words = 10
passes = 20
lda模型demo代码,lsi代码相同。
for topic in lda.print_topics(num_words=num_words):
termNumber = topic[0]
print(topic[0], ':', sep='')
listOfTerms = topic[1].split('+')
for term in listOfTerms:
listItems = term.split('*')
print(' ', listItems[1], '(', listItems[0], ')', sep='')
lda_list.append(listItems[1])
测试结果1
Dictionary(81 unique tokens: ['dig', 'shoot', 'lot', 'world', 'possible']...)
# lsi result
0:
"python" (0.457)
"book" ( 0.391)
"project" ( 0.261)
"like" ( 0.196)
"application" ( 0.130)
"topic" ( 0.130)
"new" ( 0.130)
"openstack" ( 0.130)
"way" ( 0.130)
"decided"( 0.130)
# lda result
0:
"python" (0.041)
"book" ( 0.036)
"project" ( 0.026)
"like" ( 0.021)
"scalable" ( 0.015)
"turn" ( 0.015)
"working" ( 0.015)
"openstack" ( 0.015)
"scaling" ( 0.015)
"different"( 0.015)
测试结果2
Dictionary(81 unique tokens: ['happy', 'idea', 'tool', 'new', 'shoot']...)
# lsi result
0:
"python" (0.457)
"book" ( 0.391)
"project" ( 0.261)
"like" ( 0.196)
"scaling" ( 0.130)
"application" ( 0.130)
"turn" ( 0.130)
"working" ( 0.130)
"openstack" ( 0.130)
"topic"( 0.130)
# lda result
0:
"python" (0.041)
"book" ( 0.036)
"project" ( 0.026)
"like" ( 0.021)
"decided" ( 0.015)
"different" ( 0.015)
"turn" ( 0.015)
"writing" ( 0.015)
"working" ( 0.015)
"application"( 0.015)
【问题讨论】:
标签: python gensim topic-modeling