jpmml/jpmml-evaluator

Refine exception types

nstickels opened this issue · 3 comments

I created a PMML file from a GradientBoostedClassifier, and when I read it in and try to run evaluate with the jpmml-evaluator, I get this error:

Exception in thread "main" org.jpmml.evaluator.MissingFieldException: Field "decisionFunction(1)" is not defined

Just for background, this is the first time I am trying to use the jpmml-evaluator.

Adding some details if it helps:
Python 3.7.11
scikit-learn 1.0
sklearn2pmml 0.77.1

I am attaching my pmml file
My_Decision_Tree.zip

If it helps at all, this is an example of an argument Map I am passing to the evaluate method:

{x8=0.5576039608509722, x9=1.5877997202669285, x10=0.732023024806623, x12=-0.7792926138639369, x11=0.550484700051824, x14=2.613212397084671, x13=-0.47373988630212616, x16=1.4014339873470243, x15=1.4047679393623018, x18=2.6295631902493195, x17=-0.28511137108902834, x19=1.9677057493580066, x21=-0.2956167584923409, x20=0.6818925861846822, x23=-0.05085576146969522, x1=-0.08933619679619846, x22=0.22060139230222456, x2=0.788569403418697, x25=0.2528517678666765, x3=-0.029116595925257116, x24=-0.719646872515488, x4=0.22679345376677662, x5=0.6479892341544667, x6=-0.07084623372637831, x7=0.7739668051293385}

Though for the record, this happens with every argument Map I have tried passing in.

Exception in thread "main" org.jpmml.evaluator.MissingFieldException: Field "decisionFunction(1)" is not defined

Next time, please provide THREE STACK FRAMES OF CONTEXT for the exception that you're seeing.

The context would make it immediately clear which component is experiencing the difficulty.

org.jpmml.evaluator.MissingFieldException: Field "decisionFunction(1)" is not defined

TLDR: The JPMML-Evaluator library cannot proceed with the next computation step (here, most likely sigma(decisionFunction(0))), because the required result from the previous computation step is missing (decisionFunction(0)).

Ideally, the JPMML-Evaluator library should be throwing a MissingField**Value**Exception in this case (not MissingFieldException). Will address it in the 1.6.X development branch.

{x8=0.5576039608509722, .., x7=0.7739668051293385}

Your PMML model expects 26 input values (x1 .. x26). However, your argument map only contains 25 input values.

The JPMML-Evaluator library cannot find one required input value, and therefore the first stage of the GBT model returns a missing prediction, which causes the decisionFunction(0) field value to be missing/undefined, which causes the MissingFieldException to be thrown.

TLDR 2: Add the missing input value to your arguments map, and everything should be OK.

Thank you @vruusmann. That was my mistake for missing one column. When I fixed that it works perfectly.

When I fixed that it works perfectly.

Great!

Anyway, let's keep this issue open, as it indicates a significant deficiency in user-friendliness - nothing in the original exception message suggests that there might be something wrong with model arguments.

I was able to quickly diagnose it, because I've seen it many times before. There should be several issues along the same lines around several JPMML repositories (sometimes the issue is reported in reference to the converter, sometimes the evaluator).

The problem persists up to this day, but it will be solved in 2022!