SauceCat / PDPbox

python partial dependence plot toolbox
http://pdpbox.readthedocs.io/en/latest/
MIT License
840 stars 129 forks source link

The provided example do not work #70

Closed oroojlooy closed 3 years ago

oroojlooy commented 4 years ago

When I run the first example,

from pdpbox import info_plots, get_dataset

test_titanic = get_dataset.titanic()
titanic_data = test_titanic['data']
titanic_target = test_titanic['target']
fig, axes, summary_df = info_plots.target_plot(
    df=titanic_data, feature='Sex', feature_name='Sex', target=titanic_target)

I get the following error:

---------------------------------------------------------------------------
XGBoostError                              Traceback (most recent call last)
<ipython-input-3-41ad02fb9c3f> in <module>
      1 from pdpbox import info_plots, get_dataset
      2 
----> 3 test_titanic = get_dataset.titanic()
      4 titanic_data = test_titanic['data']
      5 titanic_target = test_titanic['target']

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pdpbox\get_dataset.py in titanic()
      7 
      8 def titanic():
----> 9         dataset = joblib.load(os.path.join(DIR, 'datasets/test_titanic.pkl'))
     10         return dataset
     11 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\numpy_pickle.py in load(filename, mmap_mode)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\numpy_pickle.py in _unpickle(fobj, filename, mmap_mode)
    524     obj = load(filename, mmap_mode)
    525     JOBLIB_MMAPS.add(obj.filename)
--> 526     if unlink_on_gc_collect:
    527         add_maybe_unlink_finalizer(obj)
    528     return obj

~\AppData\Local\Continuum\anaconda3\lib\pickle.py in load(self)
   1086                     raise EOFError
   1087                 assert isinstance(key, bytes_types)
-> 1088                 dispatch[key[0]](self)
   1089         except _Stop as stopinst:
   1090             return stopinst.value

~\AppData\Local\Continuum\anaconda3\lib\site-packages\joblib\numpy_pickle.py in load_build(self)
    337             # If any NDArrayWrapper is found, we switch to compatibility mode,
    338             # this will be used to raise a DeprecationWarning to the user at
--> 339             # the end of the unpickling.
    340             if isinstance(array_wrapper, NDArrayWrapper):
    341                 self.compat_mode = True

~\AppData\Local\Continuum\anaconda3\lib\pickle.py in load_build(self)
   1550         setstate = getattr(inst, "__setstate__", None)
   1551         if setstate is not None:
-> 1552             setstate(state)
   1553             return
   1554         slotstate = None

~\AppData\Local\Continuum\anaconda3\lib\site-packages\xgboost\core.py in __setstate__(self, state)
   1002             ptr = (ctypes.c_char * len(buf)).from_buffer(buf)
   1003             _check_call(
-> 1004                 _LIB.XGBoosterUnserializeFromBuffer(handle, ptr, length))
   1005             state['handle'] = handle
   1006         self.__dict__.update(state)

~\AppData\Local\Continuum\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: [22:04:57] C:\Users\Administrator\workspace\xgboost-win64_release_1.2.0\src\learner.cc:891: Check failed: header == serialisation_header_: 

  If you are loading a serialized model (like pickle in Python) generated by older
  XGBoost, please export the model by calling `Booster.save_model` from that version
  first, then load it back in current version.  There's a simple script for helping
  the process. See:

    https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html

  for reference to the script, and more details about differences between saving model and
  serializing.

I have the latest version of xgboost.

SauceCat commented 3 years ago

It's fixed in the new version.