Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'XGBModel' object has no attribute 'callbacks'

Traceback (most recent call last): File "D:\Miniconda3\envs\ppy39\lib\site-packages\flask\app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "D:\Miniconda3\envs\ppy39\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "D:\Miniconda3\envs\ppy39\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "D:\Miniconda3\envs\ppy39\lib\site-packages\flask\app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "C:\Users\admin\Desktop\VScode\WorkProjects\2022\Product_Classification\retention_ml.py", line 169, in output_result
result_28 = xgboost_reg_281.predict(data[col_reg_28]) File "D:\Miniconda3\envs\ppy39\lib\site-packages\xgboost\sklearn.py", line 1047, in predict if self._can_use_inplace_predict(): File "D:\Miniconda3\envs\ppy39\lib\site-packages\xgboost\sklearn.py", line 983, in _can_use_inplace_predict predictor = self.get_params().get("predictor", None) File "D:\Miniconda3\envs\ppy39\lib\site-packages\xgboost\sklearn.py", line 636, in get_params params.update(cp.class.get_params(cp, deep)) File "D:\Miniconda3\envs\ppy39\lib\site-packages\xgboost\sklearn.py", line 633, in get_params params = super().get_params(deep) File "D:\Miniconda3\envs\ppy39\lib\site-packages\sklearn\base.py", line 205, in get_params value = getattr(self, key) AttributeError: 'XGBModel' object has no attribute 'callbacks'

like image 641
James Lee Avatar asked Oct 23 '25 11:10

James Lee


2 Answers

Check your xgboost library version. I loaded a model saved from xgboost==1.5.0 env to a xgboost==1.6.0 env and got the same error when operating on the model. I downgraded xgboost to 1.5.0 and everything worked fine. I suspect the model saving format is changing since 1.6.0 as it gives warning about me loading a binary model file using pickle dump.

like image 163
Dian Yu Avatar answered Oct 25 '25 00:10

Dian Yu


We made:

!pip install xgboost==1.5.0

And it ran perfectly

like image 43
Roberto Suárez Avatar answered Oct 25 '25 01:10

Roberto Suárez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!