pyclustering
pyclustering copied to clipboard
Predict function throwing error on demo code.
Hi sorry but I think I found a massive bug in the code. For some reason when I call predict on the model it gives me back the following:
I think this might be a massive bug problem...can anyone help with this?
It seems like a very simple fix of changing object1 and object2 to the correct datatype.
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.