JPMML Evaluator InputFields after Transformation

23 views
Skip to first unread message

Diana Epureanu

unread,
Jun 27, 2020, 3:22:00 PM6/27/20
to Java PMML API
Hi,

Is it possible to get the InputFields used by the model after they have been processed?
I can currently read all the InputFields, but in the ModelSchema of the MiningModel I can see the actual processed fields. I do not know how I can access them.
Thank you.

Villu Ruusmann

unread,
Jun 27, 2020, 4:36:21 PM6/27/20
to Java PMML API
Hi Diana,

>
> Is it possible to get the InputFields used by the model
> after they have been processed?
>

Do you understand you correctly - you'd like to get a list of all
field values that were "used" by the MiningModel element during the
prediction? For example, in addition to regular input fields (aka
active fields), you'd like to see the values of derived fields
(defined by TransformationDictionary/DerivedField and
LocalTransformations/DerivedField elements)?

If you, then you'd need to obtain a reference to the
org.jpmml.evaluator.(Mining)ModelEvaluationContext object that was
used by the (Mining)ModelEvaluator during the evaluation of a
particular data record.

The EvaluationContext class is a semi-private API, so it will be
tricky to get access to it.

It's created by the ModelEvaluator#createEvaluationContext() method
(overriden in MiningModelEvaluator to return a
MiningModelEvaluationContext instead of ModelEvaluationContext):
https://github.com/jpmml/jpmml-evaluator/blob/1.5.1/pmml-evaluator/src/main/java/org/jpmml/evaluator/ModelEvaluator.java#L263-L265

Its life cycle is rather short:
https://github.com/jpmml/jpmml-evaluator/blob/1.5.1/pmml-evaluator/src/main/java/org/jpmml/evaluator/ModelEvaluator.java#L279-L307

Anyway, the information that you're looking for - all field values -
is available as EvaluationContext#getValues():
https://github.com/jpmml/jpmml-evaluator/blob/1.5.1/pmml-evaluator/src/main/java/org/jpmml/evaluator/EvaluationContext.java#L166-L168

For quick experimentation, I'd suggest you to modify
org.jpmml.evaluator.ModelEvaluator source code, and do a simple
"System.out.println(context.getValues());" right after the
ModelEvaluator#evaluateInternal(context) method has returned:
https://github.com/jpmml/jpmml-evaluator/blob/1.5.1/pmml-evaluator/src/main/java/org/jpmml/evaluator/ModelEvaluator.java#L297


VR
Reply all
Reply to author
Forward
0 new messages