コード例 #1
0
# Import
import sys
sys.path.append('../')
import loadData
import datetime

# Data
data = loadData.getID2Data()
data_ordered = []

N = len(data)
i = N - 1
while i >= 0:
    data_ordered.append(data[i])
    i -= 1

file = open("../Trans_Data/ID2_ordered.csv", "w")
file.write("latitude,longitude,time\n")
for p in data_ordered:
    file.write(str(p[0]) + ',' + str(p[1]) + ',' + str(p[2]) + "\n")
file.close()
コード例 #2
0
__author__ = "Gabriel"

"""
Kmean on position
"""

import loadData as ld
import clustering as clus

import sklearn.cluster as cluster
import numpy as np
from statistics import mean, median


data = ld.getID2Data()

######If you want to select particular moments in the day
timeShift = -8  # San Francisco
data = ld.dataSelectTime(data, 0, 24, [0, 1, 2, 5, 6], timeShift)

####### Modulo 24 hours
# data = clus.temporalAround24removed(data)
data = clus.temporalAround7Daysremoved(data)
#######Remove time
# data=clus.removeTime(data)

kk = cluster.KMeans(n_clusters=5, random_state=0)
out = kk.fit(data)

clus.plotCluster(data, out.labels_, 5)
print("Cluster center " + str(out.cluster_centers_))