Apply PMML predictor model in python

自作多情 提交于 2019-12-04 22:16:30

问题


Knime has generated for me a PMML model. At this time I want to apply this model to a python process. What is the right way to do this?

More in depth: I develop a django student attendance system. The application is already so mature that I have time to implement the 'I'm feeling lucky' button to automatically fill an attendance form. Here is where PMML comes in. Knime has generated a PMML model that predicts student attendance. Also, thanks to django for being so productive that I time for this great work ;)


回答1:


Finally I have wrote my own code. Be free to contribute or fork it:

https://github.com/ctrl-alt-d/lightpmmlpredictor




回答2:


The code for Augustus, to score PMML models in Python, is at https://code.google.com/p/augustus/




回答3:


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

from pypmml import Model

model = Model.fromFile('the/pmml/file/path')
result = model.predict(data)

The data could be dict, json, Series or DataFrame of Pandas.

If you use PMML in PySpark, you could use PyPMML-Spark, for example:

from pypmml_spark import ScoreModel

model = ScoreModel.fromFile('the/pmml/file/path')
score_df = model.transform(df)

The df is a DataFrame of PySpark.

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



来源:https://stackoverflow.com/questions/15577427/apply-pmml-predictor-model-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!