Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a scikit model in a fast `.so`

What should be better path to convert a scikit model (e.g. the result of a RandomForestClassifier fit) in a piece of C++ to get the the fastest .so that can be called from some other ecosystem ?

like image 578
user3313834 Avatar asked Jul 18 '16 07:07

user3313834


People also ask

How do I save a model as a pickle file?

To save the model all we need to do is pass the model object into the dump() function of Pickle. This will serialize the object and convert it into a “byte stream” that we can save as a file called model.

Can you pickle sklearn models?

You can use the pickle operation to serialize your machine learning algorithms and save the serialized format to a file. Later you can load this file to deserialize your model and use it to make new predictions.


1 Answers

For portability of trained scikit learn models to other languages, see the sklearn-porter project.

Though, whether this will be faster than the originalRandomForestClassifier.predict method (which is multithreaded and uses numpy operations, potentially with a fast BLAS library) remains to be seen.

like image 156
rth Avatar answered Sep 22 '22 11:09

rth