将PMML - 模型(人工神经网络)转换为Java代码 [英] Convert PMML - Model (Artificial Neural Network) to Java Code

查看:287
本文介绍了将PMML - 模型(人工神经网络)转换为Java代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个训练有素的人工神经网络(ANN)的PMML文件。我想创建一个简单接受输入并返回目标值的Java方法。



这看起来很简单,但我不知道如何实现它。 / p>

PMML版本= 3.0



更新:24.05.2013



我尝试使用jpmml Java API。



这就是我的工作方式:



(1)通过Maven Central Repository下载(链接)三个.Jar文件:




  • pmml-manager-1.0.2.jar

  • pmml-model-1.0.2.jar

  • pmml-evaluator-1.0.2.jar



(2)使用eclipse配置构建路径并添加了三个外部.Jar的



(3)导入名为text的PMML文件.xml(人工神经网络(ANN))PMML版本=3.0



(4)试图运行一个例子 TreeModelTraversalExample.java 由jpmml-project提供



显然由于某些原因它不起作用:




  • 上述例子不适用于ANN。 如何重写?

  • 我的PMML文件采用XML格式。 格式是否正确?

  • 我不知道如何处理或添加Java API。 我是否应该在eclipse中通过配置构建路径添加它们?



明显的事实#2,I不知道我做了什么: - )



再次感谢和最亲切的问候。



Stefan

解决方案

JPMML应该能够处理PMML 3.X及更新版本的 NeuralNetwork 模型没有问题。此外,它应该能够处理可能伴随这些模型的所有规范化和非规范化转换。



我可以使用一个澄清说明为什么你有兴趣将PMML模型转换为Java代码首先。这使整个问题复杂化,并没有增加任何价值。 JPMML库本身相当紧凑,并且具有最小的外部依赖性(在编写本文时,它仅取决于commons-math)。在性能方面应该没有太大差异。您可以合理地期望在现代台式计算机上获得高达10,000的scorings / sec。



JPMML代码库最近已移至GitHub: http://github.com/jpmml/jpmml



研究员Turn Inc.已经分叉了这个代码库,正在为选定的模型类型实现PMML-to-Java转换(参见顶级模块pmml-translation): https://github.com/turn/jpmml



目前我建议您查看Openscoring项目(用途) JPMML内部): http://www.openscoring.org



然后,您可以尝试以下操作:


  1. 使用HTTP PUT方法部署XML文件。

  2. 使用HTTP GET方法获取模型摘要信息。如果请求成功(而不是使用HTTP状态500错误代码失败),那么您的模型得到了很好的支持。

  3. 使用HTTP以单预测模式或批量预测模式执行模型POST方法。尝试发送更大的批次以查看它是否符合您的性能要求。

  4. 使用HTTP DELETE方法取消部署模型。

您可以随时尝试联系项目所有者以获得更多信息。我相信他们是好人。


I have a PMML file of a trained Artificial Neural Network (ANN). I would like to create a Java method which simply takes in the inputs and returns the targeted value.

This seems pretty easy, but I do not know how realize it.

The PMML Version = 3.0

Update: 24.05.2013

I tried to use the jpmml Java API.

This is how I have done:

(1) Downloaded via Maven Central Repository (link) three .Jar files:

  • pmml-manager-1.0.2.jar
  • pmml-model-1.0.2.jar
  • pmml-evaluator-1.0.2.jar

(2) Used eclipse to "configure Build path" and added those three external .Jar's

(3) Import my PMML-File named "text.xml" ( an artificial neural network (ANN)) PMML version="3.0"

(4) Tried to run an example "TreeModelTraversalExample.java" provided by the jpmml-project

Obviously it did not work for some reasons:

  • the mentioned example is not for ANN's. How to rewrite it?
  • my PMML-file is in XML-format. Is it the right format?
  • I do not know how to handle or to add Java API's. Should I even add those by "configure build path" in eclipse?

Obvious fact #2, I have no clue what I do :-)

Thanks again and kindest regards.

Stefan

解决方案

JPMML should be able to handle PMML 3.X and newer versions of NeuralNetwork models without problem. Moreover, it should be able to handle all the normalization and denormalization transformations that may accompany such models.

I could use a clarification that why are you interested in converting PMML models to Java code in the first place. This complicates the whole matter a lot and it doesn't add any value. The JPMML library itself is rather compact and has minimal external dependencies (at the moment of writing this, it only depends on commons-math). There shouldn't be much difference performance-wise. You can reasonably expect to obtain up to 10'000 scorings/sec on a modern desktop computer.

The JPMML codebase has recently moved to GitHub: http://github.com/jpmml/jpmml

Fellow coders in Turn Inc. have forked this codebase and are implementing PMML-to-Java translation (see top-level module "pmml-translation") for selected model types: https://github.com/turn/jpmml

At the moment I recommend you to check out the Openscoring project (uses JPMML internally): http://www.openscoring.org

Then, you could try the following:

  1. Deploy your XML file using the HTTP PUT method.
  2. Get your model summary information using the HTTP GET method. If the request succeeds (as opposed to failing with an HTTP status 500 error code) then your model is well supported.
  3. Execute the model either in single prediction mode or batch prediction mode using the HTTP POST method. Try sending larger batches to see if it meets your performance requirements.
  4. Undeploy the model using the HTTP DELETE method.

You can always try contacting project owners for more insight. I'm sure they are nice people.

这篇关于将PMML - 模型(人工神经网络)转换为Java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆