Use PMML models in Python

Tendero picture Tendero · Sep 18, 2018 · Viewed 7.8k times · Source

I've found many topics related to this on the Internet but I could find no solutions.

Suppose I want to download any PMML model from this examples list, and run them in Python (Python 3 preferably). Is there any way to do this?

I'm looking for a way to import a PMML that was deployed OUTSIDE Python and import it to use it with this language.

Answer

PredictFuture picture PredictFuture · Jul 25, 2019

You could use PyPMML to apply PMML in Python, for example:

from pypmml import Model

model = Model.fromFile('DecisionTreeIris.pmml')
result = model.predict({
    "Sepal_Length" : 5.1,
    "Sepal_Width" : 3.5,
    "Petal_Length" : 1.4,
    "Petal_Width" : 0.2
})

For more info about other PMML libraries, be free to see: https://github.com/autodeployai