Home > other >  AttributeError: 'XGBModel' object has no attribute 'callbacks'
AttributeError: 'XGBModel' object has no attribute 'callbacks'

Time:04-22

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'

CodePudding user response:

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.

CodePudding user response:

We made:

!pip install xgboost==1.5.0

And it ran perfectly

  • Related