pickle problem in custom python model
![RoelVanderPaal](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar4.png)
RoelVanderPaal
Registered Posts: 1 ✭✭✭✭
I try to use a custom python model for predicting and I started by using the MajorityClassifier from http://scikit-learn.org/stable/developers/contributing.html#rolling-your-own-estimator
I get the following error when training this model: Can't pickle
Is there a way around this?
I get the following error when training this model: Can't pickle
Is there a way around this?
Tagged:
Answers
-
Hi,
Unfortunately, no workaround is possible "as-is". The pickle concept requires that the class be defined in a top level namespace, which is not the case here in a block of code which is evaluated dynamically.
The solution is to put your custom class in a separate file, and put that file in the DATA_DIR/lib/python folder of DSS. This folder is automatically added to the Python path. The code of your custom model then becomes only the instantiation of this class, which does not cause any issue.