Got this error while try to load my ML model : _pickle.UnpicklingError: invalid load key

I got this error when try to load my ML model using pickle, i checked my requirements and everything are correct. Can anyone help me with this problem, thanks!

This is my apps:

This is my github:

I assume that the data types from the pickle file are unknown at the time of loading. I would therefore also add the libraries used to create the model as an import statement in the file.

Thanks for the suggestion, just try it, but still the same error

IMHO pickling ML models can cause all sorts of problems.

  • different pickle format version
  • unknown types at load time
  • different versions of ML libraries used between model build and model load time

After inspecting your pickle file i assume the following ML library versions were used during the ML model creation, but i could be wrong.


Always make sure you are using the same versions of your ML libraries during model creation and model loading/using!

Thanks for the follow-up suggestion, I already checked the version, and everything matches. But I get the solution, it is just I must copy the dataframe before processing it into the model, I am not sure why, but it works fine.

unused_cols= ['vehicle_id', 'vehicle_title', 'vehicle_variant', 'vehicle_link', 'vehicle_type']

used_car_for_model = used_car.drop(unused_cols, axis=1).copy()