use of org.jpmml.evaluator.TargetField in project openscoring by openscoring.
the class ModelUtil method encodeTargetFields.
private static List<Field> encodeTargetFields(List<TargetField> targetFields) {
Function<TargetField, Field> function = new Function<TargetField, Field>() {
@Override
public Field apply(TargetField targetField) {
FieldName name = targetField.getName();
// A "phantom" default target field
if (targetField.isSynthetic()) {
name = ModelResource.DEFAULT_NAME;
}
DataField dataField = targetField.getDataField();
Field field = new Field(name.getValue());
field.setName(dataField.getDisplayName());
field.setDataType(targetField.getDataType());
field.setOpType(targetField.getOpType());
field.setValues(encodeValues(dataField));
return field;
}
};
List<Field> fields = new ArrayList<>(Lists.transform(targetFields, function));
return fields;
}
use of org.jpmml.evaluator.TargetField in project openscoring by openscoring.
the class ModelUtil method encodeSchema.
public static Map<String, List<Field>> encodeSchema(Evaluator evaluator) {
Map<String, List<Field>> result = new LinkedHashMap<>();
List<InputField> inputFields = evaluator.getInputFields();
result.put("inputFields", encodeInputFields(inputFields));
List<InputField> groupFields = Collections.emptyList();
if (evaluator instanceof HasGroupFields) {
HasGroupFields hasGroupFields = (HasGroupFields) evaluator;
groupFields = hasGroupFields.getGroupFields();
}
result.put("groupFields", encodeInputFields(groupFields));
List<TargetField> targetFields = evaluator.getTargetFields();
result.put("targetFields", encodeTargetFields(targetFields));
List<OutputField> outputFields = evaluator.getOutputFields();
result.put("outputFields", encodeOutputFields(outputFields));
return result;
}
Aggregations