I have the following pmml file:
<?xml version="1.0" ?>
<PMML>
<Header copyright="">
<Timestamp>2015-10-02 14:41:20.278000</Timestamp>
</Header>
<DataDictionary numberOfFields="5">
<DataField dataType="double" name="sepal length" optype="continuous"/>
<DataField dataType="double" name="sepal width" optype="continuous"/>
<DataField dataType="double" name="petal length" optype="continuous"/>
<DataField dataType="double" name="petal width" optype="continuous"/>
<DataField dataType="string" name="result" optype="categorical">
<Value value="iris setosa"/>
<Value value="iris versicolor"/>
<Value value="iris virginica"/>
</DataField>
</DataDictionary>
<RegressionModel functionName="regression" modelName="IrisRegression" normalizationMethod="softmax" targetFieldName="result">
<MiningSchema>
<MiningField name="sepal length"/>
<MiningField name="sepal width"/>
<MiningField name="petal length"/>
<MiningField name="petal width"/>
<MiningField name="result" usageType="predicted"/>
</MiningSchema>
<RegressionTable intercept="0.265606167976">
<NumericPredictor coefficient="0.414988328296" name="sepal length"/>
<NumericPredictor coefficient="1.46129738856" name="sepal width"/>
<NumericPredictor coefficient="-2.2621411772" name="petal length"/>
<NumericPredictor coefficient="-1.02909509924" name="petal width"/>
</RegressionTable>
<RegressionTable intercept="1.08542374239">
<NumericPredictor coefficient="0.416639685595" name="sepal length"/>
<NumericPredictor coefficient="-1.60083318526" name="sepal width"/>
<NumericPredictor coefficient="0.577657628678" name="petal length"/>
<NumericPredictor coefficient="-1.38553842866" name="petal width"/>
</RegressionTable>
<RegressionTable intercept="-1.21471457808">
<NumericPredictor coefficient="-1.70752515382" name="sepal length"/>
<NumericPredictor coefficient="-1.53426833999" name="sepal width"/>
<NumericPredictor coefficient="2.47097168077" name="petal length"/>
<NumericPredictor coefficient="2.55538211298" name="petal width"/>
</RegressionTable>
</RegressionModel>
</PMML>
When I try to evaluate it using jpmml-evaluator, I get this error : org.jpmml.evaluator.InvalidFeatureException: RegressionModel
It works fine with a linear regression. Any ideas why I get this error ? Is my pmml file wrong somehow ?
EDIT: I changed the functionName to regression
and now have the following error:
org.jpmml.evaluator.InvalidFeatureException: RegressionTable
at org.jpmml.evaluator.RegressionModelEvaluator.evaluateClassification(RegressionModelEvaluator.java:140)
at org.jpmml.evaluator.RegressionModelEvaluator.evaluate(RegressionModelEvaluator.java:70)
at org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:345)
at tryEvaluator.Example.somefunction(Example.java:75)
at tryEvaluator.Example.main(Example.java:110)
According to the PMML specification, it is illegal for a regression-type RegressionModel
element to contain more than one RegressionTable
child elements.
Here's the relevant quote:
If the model is used to predict a numerical field, then there is only one RegressionTable and the attribute targetCategory may be missing. If the model is used to predict a categorical field, then there are two or more RegressionTables and each one must have the attribute targetCategory defined with a unique value.
You can fix your PMML document by changing the value of the RegressionModel@functionName
attribute from regression
to classification
. Clearly, you're working with a classification-type problem.