Unknown Objective Function binary:logistic - XGBoost Error Pickle File

I am trying to open a pickled model onto a cloud-based server. The XGBoost version is 0.82 and my local machine’s version is 0.90 (where the pickled model was created). The Python versions are also different (3.6.4 Cloud and 3.7 Local).

I have seen in other forum responses that I may need to edit the pickle file. Is there a different objective function name for Logistic Classifier that I should be using for the XGBoost 0.82 Version?
Thank you!

When loading the model, I get the following error:

XGBoostError: b'[22:05:10] /workspace/src/objective/objective.cc:23: Unknown objective function binary:logistic\n\nStack trace returned 10 entries:\n[bt] (0) /app/.runtimes/python/lib/python3.6/site-packages/xgboost/./lib/libxgboost.so(dmlc::StackTrace(unsigned long)+0x47) [0x7f971c11cfc7]\n[bt] (1) /app/.runtimes/python/lib/python3.6/site-packages/xgboost/./lib/libxgboost.so(xgboost::ObjFunction::Create(std::string const&)+0x449) [0x7f971c174b09]\n[bt] (2) /app/.runtimes/python/lib/python3.6/site-packages/xgboost/./lib/libxgboost.so(xgboost::LearnerImpl::Load(dmlc::Stream*)+0x3a9) [0x7f971c1fb449]\n[bt] (3) /app/.runtimes/python/lib/python3.6/site-packages/xgboost/./lib/libxgboost.so(XGBoosterLoadModelFromBuffer+0x50) [0x7f971c113850]\n[bt] (4) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call_unix64+0x4c) [0x7f97a75a4adc]\n[bt] (5) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call+0x1fc) [0x7f97a75a440c]\n[bt] (6) /app/.runtimes/python/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(_ctypes_callproc+0x293) [0x7f97a77b88f3]\n[bt] (7) /app/.runtimes/python/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(+0x8e4f) [0x7f97a77afe4f]\n[bt] (8) /app/.runtimes/python/bin/…/lib/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x8b) [0x7f97af573cdb]\n[bt] (9) /app/.runtimes/python/bin/…/lib/libpython3.6m.so.1.0(+0x164e18) [0x7f97af665e18]\n\n’

You should downgrade the local machine’s XGBoost to 0.82, to match the version in the cloud server. XGBoost only promises backward compatibility, so you can load 0.82 model into 0.90 but not 0.90 model into 0.82. (Analogy: you cannot play Blu-Ray disc with a DVD player, but you can play a DVD disc with a Blu-Ray player.)

Hi @hcho3 – I have XGBoost 0.82 on my local machine with virtual environment to run & pickle model. Also have tried using Booster save_model / load_model instead of pickling. I am still getting the same XGBoostError error message as my original post. ---> 980 xgboost.core._LIB.XGBoosterLoadModelFromBuffer(bst.handle, ptr, length)

Using load_model, I get the error ‘TypeError: underlying buffer is not writable’. I have also tried using the function xgb_load_model from this Github thread which then gives the original XGBoostError again.

Any thoughts on this issue would be helpful. Thank you!

With load_model(), did you specify the path of the model file? The error message implies that you have pass a buffer instead.

Hmm no it is not a local filepath. I am passing the file content itself which is bytes type. This is because I am opening the saved model file from Github on the cloud server using GitHub API. And passing that content into load_model(raw_bytes_data). Originally, it was a pickle file where I was doing similar process … opening the pickle file and trying to open with pickle.loads().

Sorry, that use case is not supported in XGBoost. Please specify a file path as string in load_model().