0

I'm testing jpmml-evaluator. I have the following code:

PMML pmml = readPMML(new File(file));
ModelEvaluatorFactory mef = ModelEvaluatorFactory.newInstance();
ModelEvaluator<?> modelEvaluator = mef.newModelManager(pmml);
Evaluator eval = (Evaluator)modelEvaluator;

List<FieldName> active = eval.getActiveFields();
ArrayList<String> input = new ArrayList<String>();
input.add(Double.toString(test_pmml.getXP_TEST_PMML_CAPITAL()));
input.add(Double.toString(test_pmml.getXP_TEST_PMML_NBTER()));
input.add(Double.toString(test_pmml.getXP_TEST_PMML_ARRIER()));
input.add(Double.toString(test_pmml.getXP_TEST_PMML_EFFECTI()));

Map<FieldName, FieldValue> args = new LinkedHashMap<FieldName, FieldValue>();
int i = 0;
for (FieldName field : active) {
  FieldValue value = eval.prepare(field, input.get(i));
  args.put(field, value);
  i++;
}
Map<FieldName, ?> results = eval.evaluate(args);
FieldName target = eval.getTargetField();
System.out.println("target value : " + results.get(target));

And I get this error at the evaluation line :

org.jpmml.evaluator.TypeCheckException: Expected STRING, but got null

I understand the error, but I can't figure why it fires. I've made sure my args is not null, and doesn't contain any null value. No problems why the fields either. I thought maybe I wasn't converting my double values correctly, but using String.valueOf() instead of Double.toString didn't solve the problem. Is there something I'm missing here ?

MiraLief
  • 45
  • 6
  • How does `System.out.println(args);` look like? It must contain a `null` value, otherwise you wouldn't be getting this exception. – user1808924 Oct 23 '15 at 14:14
  • I get this when printing args: `{CAPITAL=ContinuousValue{opType=CONTINUOUS, dataType=DOUBLE, value=151.0}, NBTER=ContinuousValue{opType=CONTINUOUS, dataType=DOUBLE, value=5.0}, ARRIER=CategoricalValue{opType=CATEGORICAL, dataType=STRING, value=1.0}, EFFECTI=ContinuousValue{opType=CONTINUOUS, dataType=DOUBLE, value=152.0}}` – MiraLief Oct 23 '15 at 14:38
  • It looks suspicious to have a single categorical string field with value "1.0" (`ARRIER=CategoricalValue{opType=CATEGORICAL, dataType=STRING, value=1.0`), when the other three fields are continuous doubles. – user1808924 Oct 23 '15 at 14:46
  • Again, please paste the stack trace of this TypeCheckException somewhere (the top 5 lines should be enough). Then it will be very easy to see which components were involved there. There's probably something wrong with your PMML document anyway. – user1808924 Oct 23 '15 at 14:49

0 Answers0