gpt4 book ai didi

machine-learning - 对相似的词组进行分类

转载 作者:行者123 更新时间:2023-11-30 09:19:25 24 4
gpt4 key购买 nike

我有一组单词短语,我想按照下面的示例对它们进行分类。

示例:

adaptive and intelligent educational system
adaptive and intelligent tutoring system
adaptive educational system

对于人类来说,很容易理解上述三词短语应该属于一个类别。

有什么简单的方法吗?

目前,我正在使用亲和传播聚类算法,如下使用编辑距离。

words = np.asarray(words) #So that indexing with a list will work
lev_similarity = -1*np.array([[distance.levenshtein(w1,w2) for w1 in words] for w2 in words])

affprop = sklearn.cluster.AffinityPropagation(affinity="precomputed", damping=0.5)
affprop.fit(lev_similarity)
for cluster_id in np.unique(affprop.labels_):
exemplar = words[affprop.cluster_centers_indices_[cluster_id]]
cluster = np.unique(words[np.nonzero(affprop.labels_==cluster_id)])
cluster_str = ", ".join(cluster)
print(" - *%s:* %s" % (exemplar, cluster_str))

但是,我没有得到想要的输出。因此,请向我建议一种合适的方法来获得我想要的结果。

最佳答案

编辑距离适用于角色。

从这个角度来看,“教育”和“辅导”是尽可能不同的。

如果您想按语义相似度进行聚类,请不要使用字符级别相似度。

不幸的是,语义相似性很难。您将需要以某种方式使用庞大的知识库。例如,使用整个万维网来了解“辅导”和“教育”是相关的。或者你可以尝试例如WordNet 等

关于machine-learning - 对相似的词组进行分类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45542179/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com