Can't pickle `Gama` object
jimgoo opened this issue · 2 comments
Is there a way to save and load the GamaClassifier
and GamaRegressor
objects? When I try to save them with pickle using this:
clf = GammaClassifier(...)
with open('model.pkl', 'wb') as f:
pickle.dump(clf, f)
I get:
AttributeError: Can't pickle local object 'AsyncEA.__init__.<locals>.get_parent'
Thanks!
Hi, sorry for the delay!
I use some locally defined functions (including some lambdas), which prevents gama
objects from being pickled easily. Out of curiosity, why do you want to save the entire gama
object as opposed e.g. its final model?
You can pickle the final model instead:
clf = GamaClassifier(...)
clf.fit(x, y)
with open("model.pkl", "wb") as f:
pickle.dump(clf.model, f)
However gama
is not too far off from being entirely pickleable, I created a branch pickle which allows for the gama
object to be pickled. I don't entirely like the introduced top-level functions so I am not quite ready to merge it into master
yet, but it should work for your purpose if you want to use it.
I'll leave the issue open until gama
supports pickle directly (or we explicitly agree not to)
Ah ok great, saving and loading the final model works for me.
Thanks!