Georg Heiler
Georg Heiler

Reputation: 17676

python pickle object with lambdas

How can I pickle a python object which contains lambdas?

Can't pickle local object 'BaseDiscretizer.__init__.<locals>.<lambda>'

is the error I get when trying to pickle https://github.com/marcotcr/lime/blob/97a1e2d7c1adf7b0c4f0d3b3e9b15f6197b75c5d/lime/discretize.py when pickling the https://github.com/marcotcr/lime/blob/2703bcdcddd135947fe74e99cc270aa4fac3263a/lime/lime_tabular.py#L88 LimeTabularExplainer

Upvotes: 7

Views: 3577

Answers (1)

trent
trent

Reputation: 27935

The standard pickle module cannot serialize lambdas, but there is a third party package called dill which supports them.

Upvotes: 13

Related Questions