@阿隆和@Roko Mijic的接近忽視的事實功能show_topics
返回默認只有每個主題的頂部20個字。如果返回構成話題的所有單詞,那麼所有在這種情況下的近似話題概率將是1(或0.999999)。我嘗試用下面的代碼,這是@Roko Mijic的改編:
def topic_prob_extractor(gensim_hdp, t=-1, w=25, isSorted=True):
"""
Input the gensim model to get the rough topics' probabilities
"""
shown_topics = gensim_hdp.show_topics(num_topics=t, num_words=w ,formatted=False)
topics_nos = [x[0] for x in shown_topics ]
weights = [ sum([item[1] for item in shown_topics[topicN][1]]) for topicN in topics_nos ]
if (isSorted):
return pd.DataFrame({'topic_id' : topics_nos, 'weight' : weights}).sort_values(by = "weight", ascending=False);
else:
return pd.DataFrame({'topic_id' : topics_nos, 'weight' : weights});
一個更好的,但我不知道,如果是100%有效,方法一提到here。你可以得到的主題的HDP模型的真實重量(阿爾法向量)爲:
alpha = hdpModel.hdp_to_lda()[0];
審查的主題相當於α值大於清點起來的每個主題的第20個字的權重來近似更符合邏輯它在數據中的使用概率。
nope他們都在'話題'無論概率 – user86895