import matplotlib.pyplot as plt
import time
from sklearn.cluster import KMeans
from pandas import DataFrame

Data = {
	'x': [35,34,32,37,33,33,31,27,35,34,62,54,57,47,50,57,59,52,61,47,50,48,39,40,45,47,39,44,50,48],
        'y': [79,54,52,77,59,74,73,57,69,75,51,32,40,47,53,36,35,58,59,50,23,22,13,14,22,7,29,25,9,8]
       }
  
df = DataFrame(Data,columns=['x','y'])

KMeansStartTime = time.time()
   
kmeans = KMeans(n_clusters=3).fit(df)
kmeansDistance = kmeans.inertia_

kmeans = KMeans(n_clusters=4).fit(df)
kmeansDistance += kmeans.inertia_

kmeans = KMeans(n_clusters=5).fit(df)
kmeansDistance += kmeans.inertia_

KMeansStopTime = time.time()

KMeansppStartTime = time.time()
   
kmeans = KMeans(n_clusters=3, init='k-means++').fit(df)
kmeansppDistance = kmeans.inertia_

kmeans = KMeans(n_clusters=4, init='k-means++').fit(df)
kmeansppDistance += kmeans.inertia_

kmeans = KMeans(n_clusters=5, init='k-means++').fit(df)
kmeansppDistance += kmeans.inertia_

KMeansppStopTime = time.time()

print('KMeans time ', KMeansStopTime - KMeansStartTime)
print('KMeans total distance ', kmeansDistance)
print('KMeans++ time ', KMeansppStopTime - KMeansppStartTime)
print('KMeans++ total distance ', kmeansppDistance)


