Importing PMML models into Python (Scikit-learn)
Asked Answered
G

1

7

There seem to be a few options for exporting PMML models out of scikit-learn, such as sklearn2pmml, but a lot less information going in the other direction. My case is an XGboost model previously built in R, and saved to PMML using r2pmml, that I would like to use in Python. Scikit normally uses pickle to save/load models, but is it also possible to import models into scikit-learn using PMML?

Generatrix answered 14/10, 2016 at 17:36 Comment(0)
N
3

You can't connect different specialized representations (such as R and Scikit-Learn native data structures) over a generalized representation (such as PMML). You may have better luck trying to translate R data structures to Scikit-Learn data structures directly.

XGBoost is really an exception to the above rule, because its R and Scikit-Learn implementations are just thin wrappers around the native XGBoost library. Inside a trained R XGBoost object there's a blob raw, which is the model in its native XGBoost representation. Save it to a file, and load in Python using the xgb.Booster.load_model(fname) method.

If you know that you need to the deploy XGBoost model in Scikit-Learn, then why do you train it in R?

Newly answered 14/10, 2016 at 18:28 Comment(2)
If you know that you need to the deploy XGBoost model in Scikit-Learn, then why do you train it in R? Long story short - I didn't!Generatrix
Could you pleas etell me how to save XGboost blob raw object into a file. Appreciate your helpOvate

© 2022 - 2024 — McMap. All rights reserved.