fabsig / GPBoost

Combining tree-boosting with Gaussian process and mixed effects models
Other
530 stars 42 forks source link

ValueError: ctypes objects containing pointers cannot be pickled #94

Closed Nick-Yazdani closed 1 year ago

Nick-Yazdani commented 1 year ago

Ran into this error when trying to serialize a scikit-learn pipeline that was composed of StandardScaler and GPBoostRegressor (after it had been fit).

fabsig commented 1 year ago

Thank you for using GPBoost. This is a duplicate of #44. Using pickle does not work because of most of the data is not kept in Python but in "C++".

GPBoost models can be saved and loaded from files using internal functions as illustrated here: https://github.com/fabsig/GPBoost/blob/d374619055f2b648cb7b5a44cfd15facc339f4fb/examples/python-guide/GPBoost_algorithm.py#L255

Nick-Yazdani commented 1 year ago

May I ask what the point of having a scikit-learn wrapper is if we can't serialize sklearn pipelines that contain the wrapped model?

fabsig commented 1 year ago

Thanks for pointing this out. I added this feature. Starting from version 1.1.0, scikit-learn wrapper API models can be saved and loaded. See here for an example: https://github.com/fabsig/GPBoost/blob/b759d40199768f21ce6c41261722dc032c7bf651/examples/python-guide/sklearn_example.py#L115

Nick-Yazdani commented 1 year ago

Oh wow, that is excellent. Thank you so much!