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
评论列表
文章目录