-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (28 loc) · 956 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import matplotlib.pyplot as plt
import Point
import controller as controller
import const as const
import random
samples = controller.define_samples()
for i in range(0, const.number_samples):
print("X:",samples[i].x,"Y",samples[i].y)
centroids = controller.define_centroids(samples)
for centroid in centroids:
centroid.show()
for i in range(0,100):
clusters = controller.match_samples(samples,centroids)
controller.refresh_centroids(samples,centroids, clusters)
# x=0
# for cluster in clusters:
# print("cluster ",x)
# for i in range(0,len(cluster)):
# print(" element: ")
# cluster[i].show()
# x=x+1
colors = []
for i in range(0,const.k):
colors.append( (random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)))
for sample in samples:
print(sample.get_match())
plt.plot(sample.x, sample.y, marker='o', markersize=6, color=colors[sample.get_match()])
plt.show()