I'm trying to load a trained XGBoost model which has been saved in a json file. I'm using the following code:
params= {'objective' : 'multi:softmax',
'eval_metric': 'mlogloss',
'num_class': 10,
'early_stopping_rounds': 10}
xgb = xgb.XGBClassifier(**params)
xgb.load_model("xgb_default.json")
However I'm getting an error. I will include it in here together with the Traceback:
XGBoostError Traceback (most recent call last)
<ipython-input-4-8a9abeb40a78> in <module>
10
11 xgb = xgb.XGBClassifier(**params)
---> 12 xgb.load_model("xgb_default.json")
~\anaconda3\lib\site-packages\xgboost\sklearn.py in load_model(self, fname)
412 if not hasattr(self, '_Booster'):
413 self._Booster = Booster({'n_jobs': self.n_jobs})
--> 414 self._Booster.load_model(fname)
415 meta = self._Booster.attr('scikit_learn')
416 if meta is None:
~\anaconda3\lib\site-packages\xgboost\core.py in load_model(self, fname)
1601 # assume file name, cannot use os.path.exist to check, file can be
1602 # from URL.
-> 1603 _check_call(_LIB.XGBoosterLoadModel(
1604 self.handle, c_str(os_fspath(fname))))
1605 elif isinstance(fname, bytearray):
~\anaconda3\lib\site-packages\xgboost\core.py in _check_call(ret)
186 """
187 if ret != 0:
--> 188 raise XGBoostError(py_str(_LIB.XGBGetLastError()))
189
190
XGBoostError: [11:07:00] C:\Users\Administrator\workspace\xgboost-win64_release_1.2.0\include\xgboost/json.h:65: Invalid cast, from Null to Array
Does anyone know what is the issue here? Thank you in advance!