dmlc / xgboost

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
https://xgboost.readthedocs.io/en/stable/
Apache License 2.0
26.32k stars 8.73k forks source link

Error while loading model:basic_string::resize #7056

Closed COLLEENCAI closed 3 years ago

COLLEENCAI commented 3 years ago

filemodel = 'xgboostModel.trail04.save'

Saved the model using the following with open(filemodel, 'wb') as f: pickle.dump(model, f)

I am able to run the following lines to make prediciton with open(filemodel, 'rb') as f: xgb_srm = pickle.load(f) pred= xgb_srm.predict(dtrain)

However, when I do and receive XGBoostError: basic_string::resize param = {'colsample_bylevel': 0.5, ...} model=xgb.Booster(param) model.load_model(filemodel)

image

Could you please have a look? Thanks!

hcho3 commented 3 years ago

You cannot load a pickle file with load_model. Please use save_model first to obtain a file that can be later loaded with load_model.