location.py 文件源码

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

项目:2016CCF-unicom 作者: xuguanggen 项目源码 文件源码
def cluster(tr_lonlat_list,num_clusters,thiskey):

    dict_fileName = r'pkl/dict_'+thiskey+".pkl"
    tr_lonlat_list = np.array(tr_lonlat_list)
    kmeans = KMeans(n_clusters=num_clusters,n_jobs=-1).fit(tr_lonlat_list)
    #mf = MeanShift(bandwidth=0.001,bin_seeding=True,min_bin_freq=5).fit(tr_lonlat_list)

    lonlat_cluster_dict = {}
    for i in range(tr_lonlat_list.shape[0]):
        key = str(tr_lonlat_list[i][0])+":"+str(tr_lonlat_list[i][1])
        lonlat_cluster_dict[key] = kmeans.labels_[i]
    f_w = open(dict_fileName,'w')
    pickle.dump(lonlat_cluster_dict,f_w)
    return lonlat_cluster_dict
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号