示例#1
0
print '================================'

readFile = pd.read_csv(FILE, iterator=True, chunksize=1000, na_values = '')
points = pd.concat(readFile, ignore_index=True)

points = np.array(points, dtype=None)
loc = np.array(points[:,9:11],dtype=float)

if not os.path.isfile(DIC_FILE):
    dic = ldaAdd.dic(DIC_FILE, points)
else:
    dic = ldaAdd.readDic(DIC_FILE)


"""1st layer"""
labels, cluster_centers, n_clusters_, ms = msAdd.ms1st(0.015, loc)
print("number of estimated clusters in 1st layer: %d" % n_clusters_)
zeros = [0]*len(points)
#1st layer label
points = np.hstack((points, np.transpose([labels,zeros]) ))
#drawGmap.drawLayer(labels, cluster_centers, n_clusters_, loc, 1)


"""2nd layer"""
labels2, cluster_centers2, n_clusters_2, ms2 = msAdd.ms2nd(BW_FILE, loc)
print("number of estimated clusters in 2nd layer: %d" % n_clusters_2)

points[:,-1] = labels2
labelsNew = ms.predict(cluster_centers2) #landmark's new clus
midclus = open(MIDCLUS_FILE,'w')
for i in range(len(points)):
示例#2
0
print '===========Start Time==========='
print time.strftime('%Y-%m-%d %A %X', time.localtime(time.time()))
print '================================'

readFile = pd.read_csv(FILE, iterator=True, chunksize=1000, na_values='')
points = pd.concat(readFile, ignore_index=True)

points = np.array(points, dtype=None)
loc = np.array(points[:, 9:11], dtype=float)

if not os.path.isfile(DIC_FILE):
    dic = ldaAdd.dic(DIC_FILE, points)
else:
    dic = ldaAdd.readDic(DIC_FILE)
"""1st layer"""
labels, cluster_centers, n_clusters_, ms = msAdd.ms1st(0.015, loc)
print("number of estimated clusters in 1st layer: %d" % n_clusters_)
zeros = [0] * len(points)
#1st layer label
points = np.hstack((points, np.transpose([labels, zeros])))
#drawGmap.drawLayer(labels, cluster_centers, n_clusters_, loc, 1)
"""2nd layer"""
labels2, cluster_centers2, n_clusters_2, ms2 = msAdd.ms2nd(BW_FILE, loc)
print("number of estimated clusters in 2nd layer: %d" % n_clusters_2)

points[:, -1] = labels2
labelsNew = ms.predict(cluster_centers2)  #landmark's new clus
for i in range(len(points)):
    #for each point, find it's landmark's new clus
    points[i, -2] = labelsNew[points[i, -1]]
#drawGmap.drawLayer(labels2, cluster_centers2, n_clusters_2, loc, 2)
示例#3
0
print time.strftime('%Y-%m-%d %A %X',time.localtime(time.time())) 
print '================================'

readFile = pd.read_csv(FILE, iterator=True, chunksize=1000, na_values = '')
points = pd.concat(readFile, ignore_index=True)

points = np.array(points, dtype=None)
loc = np.array(points[:,9:11],dtype=float)

if not os.path.isfile(DIC_FILE):
    dic = ldaAdd.dic(DIC_FILE, points)
else:
    dic = ldaAdd.readDic(DIC_FILE)

"""1st layer"""
labels2, cluster_centers2, n_clusters_2, ms2 = msAdd.ms1st(0.015, loc)

dist = []
for i in range(n_clusters_2/2):
    my_members2 = labels2 == i
    if len(loc[my_members2, 0])>1:

        max_lat = 0
        min_lat = 90
        max_long = -180
        min_long = 0

        for j in range(0,len(loc[my_members2, 0])):
            # mymap2.addpoint(loc[my_members2, 1][j], loc[my_members2, 0][j], colors[i%7], title = str(i))

            # max - min