Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'
jayahm opened this issue · 7 comments
Hi,
I got this error for Single Best method.
Other methods so far were fine, but up to SB, it produced this error:
~\anaconda3\lib\site-packages\sklearn\base.py in score(self, X, y, sample_weight)
367 """
368 from .metrics import accuracy_score
--> 369 return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
370
371
~\anaconda3\lib\site-packages\deslib\static\single_best.py in predict(self, X)
110 self._check_is_fitted()
111 predicted_labels = self._encode_base_labels(self.best_clf_.predict(X))
--> 112 return self.classes_.take(predicted_labels)
113
114 def predict_proba(self, X):
TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'
In order to help you, I need to have a code example that generates this problem. Please follow the guidelines in our documentation in order to report bugs:
https://deslib.readthedocs.io/en/latest/user_guide/development.html#reporting-bugs-and-requesting-features
Without that I cannot reproduce the problem and fix it.
I was trying to follow the instruction on the documentation. But, I was not able to understand on how to share the code on gist.
Is it possible just share the code from my Dropbox?
Windows-10-10.0.18362-SP0
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
NumPy 1.19.1
SciPy 1.4.1
Scikit-Learn 0.22.1
https://www.dropbox.com/s/9o62o6uicwlajpj/DESLIB_RF.zip?dl=0
Hello,
It seems that the code you provided through dropbox was deleted so I cannot access the file to see the problem. Did you already fix the issue by yourself?
Very sorry! I was cleaning my Dropbox folders and may I didn't realize I had deleted the file.
I have restored the file and you can click the link in the previous comment.
https://www.dropbox.com/s/9o62o6uicwlajpj/DESLIB_RF.zip?dl=0
Thanks for providing me the code. I will check it and get back to you with a fix probably tomorrow
@jayahm Hello,
I think this was a very specific error with the labelencoder that was fixed in a new patch. Can you update the library with the code on master and see if the problem was solved? Now the code example you provided is working fine after the new patch.
Hi,
It is now working properly! Thanks!