Save a decision tree model in scikit

nEO picture nEO · Oct 1, 2014 · Viewed 8.2k times · Source

I'm building a decision tree using Scikit-Learn in Python. I've trained the model on a particular dataset and now I want to save this decision tree so that it can be used later (on a new dataset). Anyone knows how to do this?

Answer

Bastian Venthur picture Bastian Venthur · Dec 7, 2015

There is currently no reliable way of doing this. While pickling does work, it is not good enough, as your pickled data is not guaranteed to get properly unpickled with a later version of scikit-learn.

Quote from: http://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations

Models saved in one version of scikit-learn might not load in another version.