You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
~/envs/envs/spark_seg/lib/python3.7/site-packages/pyclustering/cluster/kmeans.py in predict(self, points)
441 for index_point in range(len(nppoints)):
442 if self.__metric.get_type() != type_metric.USER_DEFINED:
--> 443 differences[index_point] = self.__metric(nppoints[index_point], self.__centers)
444 else:
445 differences[index_point] = [self.__metric(nppoints[index_point], center) for center in self.__centers]
`from pyclustering.cluster.kmeans import kmeans, kmeans_visualizer
from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer
from pyclustering.samples.definitions import FCPS_SAMPLES
from pyclustering.utils import read_sample
samples = read_sample(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS)
initial_centers = kmeans_plusplus_initializer(samples, 2).initialize()
kmeans_instance = kmeans(samples, initial_centers)
kmeans_instance.process()
clusters = kmeans_instance.get_clusters()
final_centers = kmeans_instance.get_centers()
kmeans_instance.predict(samples)`
and i meet this:
AttributeError Traceback (most recent call last)
/tmp/ipykernel_20827/3994711565.py in
----> 1 kmeans_instance.predict(samples)
~/envs/envs/spark_seg/lib/python3.7/site-packages/pyclustering/cluster/kmeans.py in predict(self, points)
441 for index_point in range(len(nppoints)):
442 if self.__metric.get_type() != type_metric.USER_DEFINED:
--> 443 differences[index_point] = self.__metric(nppoints[index_point], self.__centers)
444 else:
445 differences[index_point] = [self.__metric(nppoints[index_point], center) for center in self.__centers]
~/envs/envs/spark_seg/lib/python3.7/site-packages/pyclustering/utils/metric.py in call(self, point1, point2)
130
131 """
--> 132 return self.__calculator(point1, point2)
133
134
~/envs/envs/spark_seg/lib/python3.7/site-packages/pyclustering/utils/metric.py in euclidean_distance_square_numpy(object1, object2)
368
369 """
--> 370 if len(object1.shape) > 1 or len(object2.shape) > 1:
371 return numpy.sum(numpy.square(object1 - object2), axis=1).T
372 else:
AttributeError: 'list' object has no attribute 'shape'
The text was updated successfully, but these errors were encountered: