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,
  
  
  Never unpickle untrusted data as it could lead to malicious code being executed upon loading.
  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.
Persisting the model parameters is the only out of the box solution in sklearn. You should ensure that:


Your model is reproducible from data
The versions of dependencies used (incl sklearn) is locked
Your QA system checks correctness of your model 


If you have these things down then the possible changes in model persistence in sklearn is a non-issue. If it happens, you just update sklearn in a controlled manner, retrain and deploy as usual.
And you avoid a whole range of other problems, for instance bugs in sklearn/numpy/whatever catching you by suprise. Or new data needs new models trained and deployed.

You can of course build your own persistence mechanism but you then need to maintain the compatibility. Better spend the effort one the above.