partitioning.py 文件源码

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

项目:rBCM 作者: lucaskolstad 项目源码 文件源码
def birch_cluster_partitioning(X, points_per_expert):
    """Return a list of lists each containing a partition of the indices of the
    data to be fit that is generated by splitting along clusters found via
    Birch clustering approach."""
    sample_sets = []
    num_samples = X.shape[0]
    indices = np.arange(num_samples)

    num_clusters = int(
            float(num_samples) / points_per_expert)
    birch = Birch(n_clusters=num_clusters, threshold=0.2)
    labels = birch.fit_predict(X)
    unique_labels = np.unique(labels)

    # Fill each inner list i with indices matching its label i
    for label in unique_labels:
        sample_sets.append([i for i in indices if labels[i] == label])
    return sample_sets
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号