相干分数0.4是好是坏?

时间:2019-02-19 09:23:17

标签: data-science

我需要知道0.4的一致性得分是好还是坏?我使用LDA作为主题建模算法。

在这种情况下,平均相干分数是多少。

3 个答案:

答案 0 :(得分:0)

连贯性衡量主题中单词之间的相对距离。 C_V有两种主要类型,通常为0

  • .3不好

    .4低

    .55可以

    .65可能会和

    一样好

    .7很好

    .8不太可能,并且

    .9可能是错误的

低一致性修复程序:

  • 调整参数alpha = .1,beta = .01或.001,种子= 123,等等

  • 获得更好的数据

  • 在.4处,您可能遇到了错误的主题数,请检查https://datascienceplus.com/evaluation-of-topic-modeling-topic-coherence/中所谓的肘方法-它为您提供了一个最佳主题数的图,以使您的数据具有最大的一致性组。我使用的短槌具有很好的连贯性,这里的代码可以检查不同主题数的连贯性:

def compute_coherence_values(dictionary, corpus, texts, limit, start=2, step=3):
    """
    Compute c_v coherence for various number of topics

    Parameters:
    ----------
    dictionary : Gensim dictionary
    corpus : Gensim corpus
    texts : List of input texts
    limit : Max num of topics

    Returns:
    -------
    model_list : List of LDA topic models
    coherence_values : Coherence values corresponding to the LDA model with respective number of topics
    """
    coherence_values = []
    model_list = []
    for num_topics in range(start, limit, step):
        model = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=num_topics, id2word=id2word)
        model_list.append(model)
        coherencemodel = CoherenceModel(model=model, texts=texts, dictionary=dictionary, coherence='c_v')
        coherence_values.append(coherencemodel.get_coherence())

    return model_list, coherence_values
# Can take a long time to run.
model_list, coherence_values = compute_coherence_values(dictionary=id2word, corpus=corpus, texts=data_lemmatized, start=2, limit=40, step=6)
# Show graph
limit=40; start=2; step=6;
x = range(start, limit, step)
plt.plot(x, coherence_values)
plt.xlabel("Num Topics")
plt.ylabel("Coherence score")
plt.legend(("coherence_values"), loc='best')
plt.show()

# Print the coherence scores
for m, cv in zip(x, coherence_values):
    print("Num Topics =", m, " has Coherence Value of", round(cv, 4))
    
# Select the model and print the topics
optimal_model = model_list[3]
model_topics = optimal_model.show_topics(formatted=False)
pprint(optimal_model.print_topics(num_words=10))

我希望这会有所帮助:)

答案 1 :(得分:0)

除了萨拉的出色回答:

UMass coherence衡量在语料库中两个单词(Wi,Wj)一起出现的频率。定义为:

D(Wi, Wj) = log [ (D(Wi, Wj) + EPSILON) / D(Wi) ]

其中: D(Wi,Wj)是单词Wi和单词Wj一起出现的次数

D(Wi)是单词Wi单独出现在语料中的次数

EPSILON是一个较小的值(like 1e-12),已添加到分子中以避免出现0个值

如果Wi和Wj从未一起出现,则将导致log(0)破坏宇宙。 EPSILON值可以解决此问题。

总而言之,您可以从非常大的负数一直到大约0为止获得一个值。解释与Sara所写的相同,数字越大越好,其中0显然是错误的。

答案 2 :(得分:0)

我想补充一点,好坏取决于您正在研究的语料以及其他聚类的得分。

在Sara提供的链接中,文章显示33个主题为最佳主题,一致性得分约为0.33,但是正如作者提到的那样,该类中可能存在重复的术语。在这种情况下,您必须将最佳聚类分解中的术语/摘要与较低的相干分数进行比较,以查看结果是否可解释。

当然,您应该调整模型的参数,但是分数与上下文相关,并且我认为您不一定可以说特定的连贯分数可以在不首先了解数据外观的情况下将数据最佳地聚类。就是说,就像萨拉提到的〜1或〜0可能是错误的。

您可以将模型与基准数据集进行比较,如果模型具有更高的一致性,则可以更好地衡量模型的运行状况。

本文对我有帮助:https://rb.gy/kejxkz