コード例 #1
0
'''
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.getID1Data()

data = ld.dataSelectTime(data,10,16,[0,1,2,3,4],1)

data = clus.temporalAround24removed(data)


data=clus.removeTime(data)



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

clus.plotCluster(data,out.labels_,10)
print("Cluster center " + str(out.cluster_centers_))
ld.fromDataClusterToCsv(data,out.labels_,"Work")
コード例 #2
0
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_))
ld.fromDataClusterToCsv(data, out.labels_, "WorkingDays")

###### Select a center and get the 80% closest values to this center removed to far points
コード例 #3
0
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.getID3Data()

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

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

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

clus.plotCluster(data, out.labels_, 7)
print("Cluster center " + str(out.cluster_centers_))
ld.fromDataClusterToCsv(data, out.labels_, "WorkingDays")

###### Select a center and get the 80% closest values to this center removed to far points