rf_location.py 文件源码

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

项目:2016CCF-unicom 作者: xuguanggen 项目源码 文件源码
def cluster(lonlat_list):


    #dic_lonlat = {}
    #for i in range(len(tr_lonlat_list)):
    #    lon = tr_lonlat_list[i][0]
    #    lat = tr_lonlat_list[i][1]
    #    key = str(lon)+":"+str(lat)
    #    if key not in dic_lonlat.keys():
    #        lonlat_list.append([lon,lat])
    #        dic_lonlat[key] = 1

    #for i in range(len(te_lonlat_list)):
    #    lon = te_lonlat_list[i][0]
    #    lat = te_lonlat_list[i][1]
    #    key = str(lon)+":"+str(lat)
    #    if key not in dic_lonlat.keys():
    #        lonlat_list.append([lon,lat])
    #        dic_lonlat[key] = 1

    #lonlat_list = np.array(lonlat_list)

    #kmeans = KMeans(n_clusters=NUM_CLUSTERS,n_jobs=-1).fit(lonlat_list)
    mf = MeanShift().fit(lonlat_list)

    lonlat_cluster_dict = {}
    for i in range(lonlat_list.shape[0]):
        key = str(lonlat_list[i][0])+":"+str(lonlat_list[i][1])
        lonlat_cluster_dict[key] = mf.labels_[i]


    #for i in range(NUM_CLUSTERS):
    #    count = 0
    #    for k,v in lonlat_cluster_dict.items():
    #        if i == v:
    #            count += 1
    #    print('cluster:'+str(i)+'\tcount:'+str(count))
    return lonlat_cluster_dict
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号