# Scikit-learn decision tree in production

I'm working at building a decision tree model that will be used in production.

In documentation here pickle is used to serialize the model however the concerns about this technique make me think there's maybe a better solution to export a model to production.

pickle (and joblib by extension), has some issues regarding maintainability and security. Because of this,

• While models saved using one version of scikit-learn might load in other versions, this is entirely unsupported and inadvisable. It should also be kept in mind that operations performed on such data could give different and unexpected results.

So my question is : Using scikit-learn, is there a safe and convenient technique to export the model into production.

PS: Converting the dot data to a python function can be a solution but i'm surprised there's no built-in solution for this.

• Why exactly is pickling the model off the table? Are there any concerns around speed of inference, frequency of model updates? Jun 22 '18 at 17:37
• Pickling makes the model dependant of the python version or of sklearn-version so i wonder if a version independant solution exists Jun 22 '18 at 19:47
• You could consider exporting the tree with tree.export as exemplified here. Jun 22 '18 at 20:26
• Indeed @mapto this is a possible solution we explore but i expected something more "built-in" Jun 22 '18 at 20:32