Create a set and points and cluster it, printing the resulting cluster centers
11 km.add_data_pt([1, 2])
12 km.add_data_pt([10, 12])
13 km.add_data_pt([0, -1])
14 km.add_data_pt([11, 13])
15 km.add_data_pt([0, 0])
16 km.add_data_pt([1, 0])
17 km.add_data_pt([9.4, 10])
18 km.add_data_pt([9.2, 11])
19 km.add_data_pt([0, 0])
29 nCenters = km.get_number_of_centers()
30 print "Number of centers (k): ", nCenters
31 for i
in range(0, nCenters):
32 print "Center ", i,
" ", km.get_center(i)
35 n = km.get_number_of_data_points()
36 assignments = km.get_assignments()
37 sqrdist = km.get_squared_distance_to_centers()
38 print "Number of points: ", n
40 print "Point ", i,
": "
41 print km.get_data_point(i)
42 print "Cluster center: ", assignments[i], \
43 " sqrt-dist: ", sqrdist[i]