import numpy as np
from catboost import CatBoostClassifier
# initialize data
train_data = np.random.randint(0, 100, size=(100, 10))
train_label = np.random.randint(0, 2, size=(100))
test_data = np.random.randint(0, 100, size=(50, 10))
# specify the training parameters
model = CatBoostClassifier(iterations=2, depth=2, learning_rate=1, loss_function='Logloss', verbose=True)
#train the model
model.fit(train_data, train_label, cat_features=[0,2,5], verbose=True)
# make the prediction using the resulting model
preds_class = model.predict(test_data)
preds_proba = model.predict_proba(test_data)
print("class = ", preds_class)
print("proba = ", preds_proba)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-e29c96272905> in <module>()
1 import numpy as np
----> 2 from catboost import CatBoostClassifier
3 # initialize data
4 train_data = np.random.randint(0, 100, size=(100, 10))
5 train_label = np.random.randint(0, 2, size=(100))
ImportError: cannot import name 'CatBoostClassifier'
I installed catboost from source like you described it in instruction
Python 3.4.2
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
When I type "python" and after that "tab", I see a several version
python
python python2.7-config python3.4m python3.5m python-html2text
python2 python2-config python3.4m-config python3.5m-config
python2.7 python3.4 python3.5 python-config
My os is Cent Os 7
Which python do u use by default (python --version)?
The problem could be that u installed CatBoost for python2.7 and trying to use it in python 3.4.
Unfortunately we have no wheel for python 3.4, so u can try to clone CatBoost from github and build wheel for your python version.
Any updates?
Closing because of inactivity.
I had this exact issue - and the problem was I had foolishly named my program file as catboost.py.
Renaming it to something else sorted the issue for me.
Most helpful comment
I had this exact issue - and the problem was I had foolishly named my program file as catboost.py.
Renaming it to something else sorted the issue for me.