clustering.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:hsarchetypes 作者: HearthSim 项目源码 文件源码
def _most_similar_pair(clusters, distance_function):
    result = []

    for c1, c2 in combinations(clusters, 2):
        if not c1.can_merge(c2):
            continue

        if c1.must_merge(c2):
            logger.info("External IDs Match.\n%s\n%s\nMust Merge" % (c1, c2))
            return c1, c2, 1.0

        sim_score = distance_function(c1, c2)
        result.append((c1, c2, sim_score))

    if result:
        sorted_result = sorted(result, key=lambda t: t[2], reverse=True)
        return sorted_result[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号