graphcluster.py 文件源码

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

项目:news-shot-classification 作者: gshruti95 项目源码 文件源码
def get_cluster_threshold(weights):

    estimator = KMeans(n_clusters = 2)
    data = np.asarray(weights)
    data = data.reshape(-1,1)
    # print data 
    clusters_idx = estimator.fit_predict(data)
    max_idx = data.argmax()
    max_cluster = clusters_idx[max_idx]
    #print max_cluster
    low_cluster = []
    if max_cluster == 1:
        indices = np.argwhere(clusters_idx == 0)
        for idx in indices:
            low_cluster.append(data[idx])
        threshold = max(low_cluster)
        threshold = threshold[0][0]
    else:
        indices = np.argwhere(clusters_idx == 1)
        for idx in indices:
            low_cluster.append(data[idx])
        threshold = max(low_cluster)
        threshold = threshold[0][0]
    # print threshold
    return threshold
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号