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

[Python] Predicted target type is string but is expected to be boolean #1954

Closed
memo26167 opened this issue Dec 14, 2021 · 0 comments
Closed
Labels

Comments

@memo26167
Copy link

memo26167 commented Dec 14, 2021

Problem: The training target is boolean and the predicted target is string. When calling the score method, it throws an error.
catboost version: 1.0.3
Operating System: Windows 10
CPU: -
GPU: -

from catboost import CatBoostClassifier
import numpy as np

clf = CatBoostClassifier(silent=True)
clf.fit(np.array([[0,1,2],[2,3,4]]), np.array([[True],[False]]))
print(clf.predict(np.array([[0,1,2],[2,3,4]])))

clf.score(np.array([[0,1,2],[2,3,4]]), np.array([[True],[False]]))

Throwing the following error

CatBoostError                             Traceback (most recent call last)
----> 1 clf.score(np.array([[0,1,2],[2,3,4]]), np.array([[True],[False]]))

\my_env\lib\site-packages\catboost\core.py in score(self, X, y)
   5032                 raise CatBoostError('predicted classes have string type but specified y is numeric')
   5033             elif np.issubdtype(y.dtype, np.bool_):
-> 5034                 raise CatBoostError('predicted classes have string type but specified y is boolean')
   5035         return np.mean(np.array(predicted_classes) == np.array(y))
   5036 

CatBoostError: predicted classes have string type but specified y is boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants