I'm using python3.5 on Ubuntu. I trained a model by xgboost sklearn wrapper and save it by pickle.
Here is a link of the pickle file: https://pan.baidu.com/s/1eSoPWxs
The question is each time I load it, the result is different.
For example:
a = pickle.load(open('mymodel', 'rb'))
b = pickle.load(open('mymodel', 'rb'))
print(a == b)
I got result False, but I think it should be True.
Can anybody explain this? Is there any way to solve this?
Thanks a lot!
When sklearn is not installed, the base class of the
XGBoostModelis the same asobject:XGBModelBase = objectAnd you probably already know that two instances of
objectare not equal:I'll expect the behavior of
__eq__on the base classXGBModelBaseto be consistent in the case sklearn is installed.Also note that
__eq__was not overriden in the model class, so the behavior you have is as expected.You may try comparing the dictionaries of the unpickled models and see if that works for you:
a.__dict__ == b.__dict__