cluster.py 文件源码

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

项目:uncover-ml 作者: GeoscienceAustralia 项目源码 文件源码
def compute_n_classes(classes, config):
    """The number of cluster centres to use for K-means

    Just handles the case where someone specifies k=5 but labels 10 classes
    in the training data. This will return k=10.

    Parameters
    ----------
    classes : ndarray
        an array of hard class assignments given as training data
    config : Config
        The app config class holding the number of classes asked for

    Returns
    -------
    k : int > 0
        The max of k and the number of classes referenced in the training data
    """
    k = mpiops.comm.allreduce(np.amax(classes), op=mpiops.MPI.MAX)
    k = int(max(k, config.n_classes))
    return k
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号