It seems to be an error when trying to pass a dict as parameter to the booster. Apparently, the "iterations"-key gets set to one of the other keys instead of its value.
`from catboost import CatBoostRegressor
import numpy as np
cat_params = {'auto_stop_pval': 0,
'depth': 6,
'feature_border_type': 'MinEntropy',
'has_time': False,
'iterations': 1000,
'l2_leaf_reg': 3,
'learning_rate': 0.03,
'loss_function': 'RMSE',
'name': 'experiment',
'random_strength': 1,
'rsm': 1,
'store_all_simple_ctr': False,
'use_best_model': False,
'verbose': False}
cat = CatBoostRegressor(cat_params)
cat.get_params()
`
[Out]
{'auto_stop_pval': 0,
'depth': 6,
'feature_border_type': 'MinEntropy',
'has_time': False,
'iterations': {'auto_stop_pval': 0,
'depth': 6,
'feature_border_type': 'MinEntropy',
'has_time': False,
'l2_leaf_reg': 3,
'learning_rate': 0.03,
'loss_function': 'RMSE',
'name': 'experiment',
'random_strength': 1,
'rsm': 1,
'store_all_simple_ctr': False,
'use_best_model': False,
'verbose': False},
'l2_leaf_reg': 3,
'learning_rate': 0.03,
'loss_function': 'RMSE',
'name': 'experiment',
'random_strength': 1,
'rsm': 1,
'store_all_simple_ctr': False,
'use_best_model': False,
'verbose': False}
This obviously wont work, so when trying to fit the booster, following error appears:
`---------------------------------------------------------------------------
CatboostError Traceback (most recent call last)
----> 1 catreg = cat.fit(X, y, eval_set= (X_val, y_val))
/home/thomas/anaconda3/lib/python3.6/site-packages/catboost/core.py in fit(self, X, y, cat_features, sample_weight, baseline, use_best_model, eval_set, verbose, plot)
432 model : CatBoost
433 """
--> 434 return self._fit(X, y, cat_features, sample_weight, baseline, use_best_model, eval_set, verbose, plot)
435
436 def _predict(self, data, weight, prediction_type, ntree_limit, verbose):
/home/thomas/anaconda3/lib/python3.6/site-packages/catboost/core.py in _fit(self, X, y, cat_features, sample_weight, baseline, use_best_model, eval_set, verbose, plot)
386 raise ImportError(e.message)
387 with log_fixup():
--> 388 self._train(X, eval_set, params)
389 if calc_feature_importance:
390 setattr(self, "feature_importance", self.feature_importances(X))
_catboost.pyx in _catboost._CatBoostBase._train (/home/rnefyodov/.ya/build/build_root/676e74667a3979746c773265657a6d73/catboost/python-package/catboost/_catboost.pyx.cpp:13630)()
_catboost.pyx in _catboost._CatBoost._train (/home/rnefyodov/.ya/build/build_root/676e74667a3979746c773265657a6d73/catboost/python-package/catboost/_catboost.pyx.cpp:9713)()
_catboost.pyx in _catboost._CatBoost._train (/home/rnefyodov/.ya/build/build_root/676e74667a3979746c773265657a6d73/catboost/python-package/catboost/_catboost.pyx.cpp:9507)()
CatboostError: library/json/writer/json_value.cpp:470: Not an integer`
Quickfix is to use the set_params() after passing the dict but before training.
That's because u trying to fit params as dict to the CatBoostClassifier, but it takes args.
Try this:
CatBoostRegressor(**cat_params)
or
CatBoost(cat_params) - but it is not support sklearn interface.
Ah, ok. Sorry, my bad.
@Donskov7 Thanks!
Most helpful comment
That's because u trying to fit params as dict to the CatBoostClassifier, but it takes args.
Try this:
CatBoostRegressor(**cat_params)
or
CatBoost(cat_params) - but it is not support sklearn interface.