Import PMML models in Python (Scikit-learn)

There seem to be several options for exporting PMML models from scikit-learn, such as sklearn2pmml, but much less information goes in the other direction. My case is the XGboost model previously built into R and stored in PMML using r2pmml, which I would like to use in Python. Scikit usually uses pickle to save / load models, but is it also possible to import models into scikit-learn using PMML?

+6
source share
2 answers

You cannot connect various specialized views (such as R and Scikit-Learn) to a generic view (such as PMML). You may be lucky that you are trying to translate R data structures into Scikit-Learn data structures directly.

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

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

+1
source

I created a simple solution to generate sklearn kmeans models from pmml files that I exported from the knime analytics platform. You can check it pmml2sklearn

0
source

Source: https://habr.com/ru/post/1269769/


All Articles