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
partialdata = clus.getThe80percentClosestToACenter(data, out, 0)

print(partialdata)

###### Second cluster on the partial data
"""
kk2 = cluster.KMeans(n_clusters=3,random_state=0)
out2 = kk2.fit(partialdata)

print(out2.cluster_centers_)
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")

partialdata = clus.getThe80percentClosestToACenter(data,out,0)

print(partialdata)

kk2 = cluster.KMeans(n_clusters=3,random_state=0)
out2 = kk2.fit(partialdata)

print(out2.cluster_centers_)


clus.plotCluster(partialdata,out2.labels_,3)