[scikit-learn] How to dump a model to txt file?

Sebastian Raschka se.raschka at gmail.com
Thu Apr 13 17:23:12 EDT 2017


Hi,

not sure how this could generally work. However, you could at least dump the model parameters for e.g., linear models and compute the prediction via

w_1 * x1 + w_2 * x_2 + … + w_n * x_n + bias

over the n features. 

To write various model attributes to text files, you could use json, e.g., see https://cmry.github.io/notes/serialize
However, I don’t think that this approach will solve the problem of loading the model into C++.

Best,
Sebastian

> On Apr 13, 2017, at 4:58 PM, 老陈 <26743610 at qq.com> wrote:
> 
> Hi,
> 
> I am working on GradientBoostingRegressor these days and I am wondering if there is a way to dump the model into txt file, or any other format that can be processed by c++
> 
> My production system is in c++, so I want use the python-trained tree model in c++ for production.
> 
> Has anyone ever done this before?
> 
> thanks
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn



More information about the scikit-learn mailing list