analyze_clustering.py 文件源码

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

项目:indefinite-pronouns 作者: dnrb 项目源码 文件源码
def get_k(clustering, depth = 10):
    """
    (ndarray, int) -> int
    clustering: ndarray -- linkage matrix representing hierarchical clustering
    depth: int -- the maximum depth to traverse clustering

    Returns the number of clusters to extract from the hierarchical clustering
    using the elbow method.
    """
    last = clustering[-depth: , 2]
    acceleration = np.diff(last, 2)
    acceleration_rev = acceleration[::-1]
    k = acceleration_rev.argmax() + 2
    return k
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号