Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Machine learning models persistence options

Any suggestions/best practices for persisting and re-using trained machine learning models ? I'm developing models in Python or R. Then these models must be used in production workflow for scoring (where R is not available). For example there could be a logistic regression model trained in R. Now new observations need to be scored against this model. The scoring engine must be fast and scalable. I've thought of following

  1. PMML (http://en.wikipedia.org/wiki/Predictive_Model_Markup_Language). It is easy to convert most of the models developed in R to pmml. However, I couldn't find a useful scoring engine for PMML models. For example, there is augustus (https://code.google.com/p/augustus/) but it implements only 3-4 models yet.

  2. Serialize the models using pickle in Python and write the consumer in Python.

Any thoughts/suggestions on the right approach ?

like image 399
hssay Avatar asked Nov 02 '22 05:11

hssay


1 Answers

Scikit-learn, a mature library in this field, uses pickle for its persistence of models. I gather you are writing your own functions to train the model, but looking at the established libraries can tell you about best practices.

On the other hand, JSON can be read from many languages. That is its main advantage. If your plan to serve model results from another language, and your models are fairly simple Python objects, then serializing them to JSON should be pretty easy.

like image 106
logc Avatar answered Nov 15 '22 04:11

logc