Predict function throwing error on demo code.
EricCacciavillani opened this issue · comments
EricCacciavillani commented
EricCacciavillani commented
It seems like a very simple fix of changing object1 and object2 to the correct datatype.
ShigemichiMatsuzaki commented
Hi,
This may be caused because the cluster centers calculated in process
are stored as list
when the k-means is performed via CCORE (the C/C++ library for pyclustering).
I've encountered the same issue and fixed this by simply editing the function process()
in the code kmeans.py
like below:
def process(self):
"""!
@brief Performs cluster analysis in line with rules of K-Means algorithm.
@return (kmeans) Returns itself (K-Means instance).
@see get_clusters()
@see get_centers()
"""
if len(self.__pointer_data[0]) != len(self.__centers[0]):
raise ValueError("Dimension of the input data and dimension of the initial cluster centers must be equal.")
if self.__ccore is True:
self.__process_by_ccore()
else:
self.__process_by_python()
# Editted
self.__centers = numpy.array(self.__centers)
return self
Although this fixed my problem, I didn't look through the entire code and am not sure this is a recommended way.
(I (we) might have missed some necessary processes.)
I'll appreciate it if someone gives me some comments.