I require that the PMML file be in format version 4.1 (not the latest 4.2.1).
How can I get sklearn2pmml to write my PMML using the schema for 4.1 or any specific version?
I don't see an option to pass a PMML version in the API:
def sklearn2pmml(estimator, mapper, pmml, verbose = False)
Thanks!
My model is classification type.
I am using the Java JPMML evaluator API to load the PMML and test my model. Funnily enough, I actually figured out that I needed to make those 2 changes, but since I encountered the exception below afterwards, I thought it might be because of some other more complicated 4.1/4.2.1 difference.
I am using version 1.0.8 of the jpmml-evaluator because I cannot use the latest version which has the Guava dependency due to integration reasons.
This is the exception:
Exception in thread "main" org.jpmml.evaluator.EvaluationException
at org.jpmml.evaluator.ParameterUtil.toDouble(ParameterUtil.java:651)
at org.jpmml.evaluator.ParameterUtil.cast(ParameterUtil.java:527)
at org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:64)
at org.jpmml.evaluator.FunctionUtil.evaluate(FunctionUtil.java:37)
at org.jpmml.evaluator.ExpressionUtil.evaluateApply(ExpressionUtil.java:168)
at org.jpmml.evaluator.ExpressionUtil.evaluate(ExpressionUtil.java:69)
at org.jpmml.evaluator.OutputUtil.evaluate(OutputUtil.java:80)
at org.jpmml.evaluator.RegressionModelEvaluator.evaluate(RegressionModelEvaluator.java:54)
at org.jpmml.evaluator.MiningModelEvaluator.evaluate(MiningModelEvaluator.java:194)
at org.jpmml.evaluator.MiningModelEvaluator.evaluateClassification(MiningModelEvaluator.java:109)
at org.jpmml.evaluator.MiningModelEvaluator.evaluate(MiningModelEvaluator.java:50)
Apparently the field name 'value' has a value of null which is trying to be cast to double. It seems to be a problem with the DefineFunction in the TransformationDictionary in the PMML. Here it is:
<TransformationDictionary>
<DefineFunction name="logit" optype="continuous" dataType="double">
<ParameterField name="value" optype="continuous" dataType="double"/>
<Apply function="/">
<Constant dataType="double">1</Constant>
<Apply function="+">
<Constant dataType="double">1</Constant>
<Apply function="exp">
<Apply function="*">
<Constant dataType="double">-1</Constant>
<FieldRef field="value"/>
</Apply>
</Apply>
</Apply>
</Apply>
</DefineFunction>
</TransformationDictionary>
Should I go ahead and file this as an issue?
Thanks Villu!
Yes, we are stuck with Guava version 11.0.2 and since JPMML is dependent on 19.0, our entire problem results from the fact that 19.0 is not backward compatible with 11.0.2 (Google removed classes along the way).
As per your suggestion, my team and I decided to use the Maven Shade plugin to relocate the conflicting Guava classes.
Did you intend that we must also use the ClassLoader to load the relocated classes from within our code?
Thanks.
Just to clear things up: our project is not directly dependent on Guava. We are dependent on JPMML which is dependent on Guava 19.0. But a parent project, which is strictly dependent on Guava 11.0.2, is dependent on our project too.
Ok, we tried the Shade example from the JPMML-Cascading example but our parent project still loads 11.0.2 only.
We noticed that the class folder com/google/common did indeed change to com/google/common19 in our JAR. However, is Shade supposed to be responsible for changing the imports in the JPMML classes too?
import com.google.common..... ==> import com.google.common19.....
Thanks.
We eventually got it working using the Shade plugin and will stick with the latest JPMML version.
Sorry the topic deviated from sklearn2pmml to support for Maven Shade.
Thanks a lot!