Create a set and points and cluster it, printing the resulting cluster centers
5 from __future__
import print_function
15 km.add_data_pt([1, 2])
16 km.add_data_pt([10, 12])
17 km.add_data_pt([0, -1])
18 km.add_data_pt([11, 13])
19 km.add_data_pt([0, 0])
20 km.add_data_pt([1, 0])
21 km.add_data_pt([9.4, 10])
22 km.add_data_pt([9.2, 11])
23 km.add_data_pt([0, 0])
33 nCenters = km.get_number_of_centers()
34 print(
"Number of centers (k): ", nCenters)
35 for i
in range(0, nCenters):
36 print(
"Center ", i,
" ", km.get_center(i))
39 n = km.get_number_of_data_points()
40 assignments = km.get_assignments()
41 sqrdist = km.get_squared_distance_to_centers()
42 print(
"Number of points: ", n)
44 print(
"Point ", i,
": ")
45 print(km.get_data_point(i))
46 print(
"Cluster center: ", assignments[i], \
47 " sqrt-dist: ", sqrdist[i])