问题描述
我有一个从 SAS Miner 生成的 PMML,我无法使用 JPMML 1.1.4 对其进行正确评估.JPMML 1.1.4 说它支持 PMML 4.2,而 PMML 说它是 PMML 4.2 版.
I have a PMML generated from SAS Miner that I can't get properly evaluated using JPMML 1.1.4. JPMML 1.1.4 says it supports PMML 4.2 and the PMML says it is PMML version 4.2.
以下函数SAS-EM-String-Normalize"中的 FMTWIDTH 是正确的 PMML 语法吗?
Is the FMTWIDTH in the below function "SAS-EM-String-Normalize" proper PMML syntax?
知道为什么我不能使用 JPMML 评估这个函数吗?
Any ideas why I can't evaluation this function using JPMML?
我的 TransformationDictionary 中的函数看起来像,
I have the function in my TransformationDictionary that looks like,
<TransformationDictionary>
<DefineFunction name="SAS-EM-String-Normalize" optype="categorical" dataType="string">
<ParameterField name="FMTWIDTH" optype="continuous"/>
<ParameterField name="AnyCInput" optype="categorical"/>
<Apply function="trimBlanks">
<Apply function="uppercase">
<Apply function="substring">
<FieldRef field="AnyCInput"/>
<Constant>1</Constant>
<Constant>FMTWIDTH</Constant>
</Apply>
</Apply>
</Apply>
</DefineFunction>
</TransformationDictionary>
我得到以下异常,
线程主"org.jpmml.evaluator.TypeCheckException 中的异常:预期为 INTEGER,但得到 STRING (FMTWIDTH)org.jpmml.evaluator.FieldValue.asInteger(FieldValue.java:125) 在org.jpmml.evaluator.FunctionRegistry$36.evaluate(FunctionRegistry.java:463)在 org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:38)在org.jpmml.evaluator.ExpressionUtil.evaluateApply(ExpressionUtil.java:203)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:91)在 org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:76)在 org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:43)在org.jpmml.evaluator.ExpressionUtil.evaluateApply(ExpressionUtil.java:203)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:91)在org.jpmml.evaluator.ExpressionUtil.evaluateApply(ExpressionUtil.java:188)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:91)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:58)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:45)在org.jpmml.evaluator.ExpressionUtil.evaluateMapValues(ExpressionUtil.java:169)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:87)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:58)在org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:45)在org.jpmml.evaluator.RegressionModelEvaluator.evaluateRegressionTable(RegressionModelEvaluator.java:150)在org.jpmml.evaluator.RegressionModelEvaluator.evaluateClassification(RegressionModelEvaluator.java:107)在org.jpmml.evaluator.RegressionModelEvaluator.evaluate(RegressionModelEvaluator.java:57)在org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:65)在ValidPMMLTesterRandomScores.randomEvaluation(ValidPMMLTesterRandomScores.java:116)在ValidPMMLTesterRandomScores.printModelInformation(ValidPMMLTesterRandomScores.java:94)在ValidPMMLTesterRandomScores.readModelFromFile(ValidPMMLTesterRandomScores.java:142)在ValidPMMLTesterRandomScores.main(ValidPMMLTesterRandomScores.java:160)
Exception in thread "main" org.jpmml.evaluator.TypeCheckException: Expected INTEGER, but got STRING (FMTWIDTH) at org.jpmml.evaluator.FieldValue.asInteger(FieldValue.java:125) at org.jpmml.evaluator.FunctionRegistry$36.evaluate(FunctionRegistry.java:463) at org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:38) at org.jpmml.evaluator.ExpressionUtil.evaluateApply(ExpressionUtil.java:203) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:91) at org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:76) at org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:43) at org.jpmml.evaluator.ExpressionUtil.evaluateApply(ExpressionUtil.java:203) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:91) at org.jpmml.evaluator.ExpressionUtil.evaluateApply(ExpressionUtil.java:188) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:91) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:58) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:45) at org.jpmml.evaluator.ExpressionUtil.evaluateMapValues(ExpressionUtil.java:169) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:87) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:58) at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:45) at org.jpmml.evaluator.RegressionModelEvaluator.evaluateRegressionTable(RegressionModelEvaluator.java:150) at org.jpmml.evaluator.RegressionModelEvaluator.evaluateClassification(RegressionModelEvaluator.java:107) at org.jpmml.evaluator.RegressionModelEvaluator.evaluate(RegressionModelEvaluator.java:57) at org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:65) at ValidPMMLTesterRandomScores.randomEvaluation(ValidPMMLTesterRandomScores.java:116) at ValidPMMLTesterRandomScores.printModelInformation(ValidPMMLTesterRandomScores.java:94) at ValidPMMLTesterRandomScores.readModelFromFile(ValidPMMLTesterRandomScores.java:142) at ValidPMMLTesterRandomScores.main(ValidPMMLTesterRandomScores.java:160)
推荐答案
根据PMML 内置函数substring"的正式定义,它需要一个字符串参数和两个整数参数.SAS EM 生成的 PMML 代码尝试使用字符串参数、整数参数和另一个字符串参数 substring($AnyCInput, 1, "FMTWIDTH")
调用此函数.
According to the formal definition of the PMML built-in function "substring", it requires a string argument and two integer arguments. The SAS EM generated PMML code attempts to invoke this function with a string argument, an integer argument, and another string argument substring($AnyCInput, 1, "FMTWIDTH")
.
可以通过使用 FieldRef
元素访问FMTWIDTH"参数的值来修复此 PMML 片段:
This PMML fragment can be fixed by accessing the value of the "FMTWIDTH" parameter using the FieldRef
element:
<Apply function="substring">
<FieldRef field="AnyCInput"/>
<Constant>1</Constant>
<FieldRef field="FMTWIDTH"/>
</Apply>
总之,JPMML 是正确的,SAS EM 是错误的.
In conclusion, JPMML is a correct and SAS EM is wrong.
这篇关于使用 JPMML 评估 SAS 生成的 PMML 文件时出现 FMTWIDTH 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!