Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predict function throwing error on demo code. #671

Open
EricCacciavillani opened this issue May 1, 2021 · 2 comments
Open

Predict function throwing error on demo code. #671

EricCacciavillani opened this issue May 1, 2021 · 2 comments

Comments

@EricCacciavillani
Copy link

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:
image

I think this might be a massive bug problem...can anyone help with this?

@EricCacciavillani
Copy link
Author

It seems like a very simple fix of changing object1 and object2 to the correct datatype.

@ShigemichiMatsuzaki
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants