tp3_solutions.py 文件源码

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

项目:TPs 作者: DataMiningP7 项目源码 文件源码
def agglomerative_clustering(X, k=10):
    """ Run an agglomerative clustering on X.

    Args:
        X: the TF-IDF matrix where each line represents a document and each
           column represents a word, typically obtained by running
           transform_text() from the TP2.
        k: the number of clusters we want (default: 10).
    Returns:
        An AgglomerativeClustering model trained on X.
    """
    model = AgglomerativeClustering(n_clusters=k)
    model.fit(X)

    # Note all the other functions are the same except we use
    # 'AgglomerativeClustering' instead of 'KMeans'.
    return model


# Ex4.1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号