big_sum=0
for j1 in range(len(self.clusters[data_tag][i].elements)):
small_sum=0
for j2 in range(len(self.clusters[data_tag][i].elements)):
small_sum+=self.clusters[data_tag][i].elements[j1].distance(
self.clusters[data_tag][i].elements[j2])
After Change
cluster.medoid = element1
// clear elements after we finished with one cluster
cluster.elements.clear()
cluster.targets.clear()
// find nearest medoid for a data point
def find_nearest_medoid(self, data_point):