PMML functions transform data in PMML models. These models include several predefined functions that are defined as Java code in the Pega PMML execution engine. Additionally, PMML producers sometimes use proprietary expressions (functions) with the PMML models that are not part of the models themselves. These functions are used for various reasons (such as performance increase or enhancements). In such cases, the PMML model contains custom functions (the model contains only references to the functions and their parameters).
Perform this procedure to add missing functions to the PMML model.
Define custom functions.
Click A function rule to define functions in the Pega Platform rule.
Select the appropriate ruleset, library, and function that implement the custom function logic.
The rulesets and libraries are appropriately filtered to reflect the current application context.
Click An external Java class to define custom functions in a JAR file that is imported in the Pega Platform.
Click Designer Studio > Application > Distribution > Import.
Import a JAR file with the proprietary expressions (functions) that you want to use with the PMML model.
Return to the Configurations tab.
Provide a name of the implementation class and method that are available in the JAR file.
The Implementation class refers to the fully qualified name of the class implementing the function.
Save the changes and restart the Pega Platform.
When you use custom functions, remember that a function takes a list of objects as argument. The order and type of the arguments is the same as defined in the PMML source definition. The output of the function must be the same type that is defined in the PMML source definition. Where applicable, you can use Java primitive types instead of the corresponding objects.
When you use a custom function in your PMML model like the one below:
public String exampleCustomFunction(List<Object> args)
{ String geographyNumericCode = (String) args.get(1);
String geographySymbolicCode = (String) args.get(2);
return geographyNumericCode + "/" + geographySymbolicCode;
}
and the model contains the corresponding data dictionary definitions:
<DataDictionary>
...
<DataField name="IMP_REP_CORP_GEOG_NUM" optype="continuous" dataType="double"/>
<DataField name="IMP_REP_CORP_GEOG_SYM" optype="categorical" dataType="string"/>
...
</DataDictionary>
<DerivedField name="IMP_REP_CORP_GEOG_CONTINENT_NM+" optype="categorical" dataType="string">
<Apply function="SAS-FORMAT-$CHARw">
<FieldRef field="IMP_REP_CORP_GEOG_NUM"/>
<FieldRef field="IMP_REP_CORP_GEOG_SYM"/>
</Apply>
</DerivedField>
Inputs to the defined function are provided in a list with two objects:
The return value from the function is an object of the java.lang.String type.