Search in sources :

Example 1 with OutputField

use of org.jpmml.evaluator.OutputField in project openscoring by openscoring.

the class ModelUtil method encodeOutputFields.

private static List<Field> encodeOutputFields(List<OutputField> outputFields) {
    Function<OutputField, Field> function = new Function<OutputField, Field>() {

        @Override
        public Field apply(OutputField outputField) {
            FieldName name = outputField.getName();
            org.dmg.pmml.OutputField pmmlOutputField = outputField.getOutputField();
            Field field = new Field(name.getValue());
            field.setName(pmmlOutputField.getDisplayName());
            field.setDataType(outputField.getDataType());
            field.setOpType(outputField.getOpType());
            return field;
        }
    };
    List<Field> fields = new ArrayList<>(Lists.transform(outputFields, function));
    return fields;
}
Also used : InputField(org.jpmml.evaluator.InputField) OutputField(org.jpmml.evaluator.OutputField) DataField(org.dmg.pmml.DataField) TargetField(org.jpmml.evaluator.TargetField) Field(org.openscoring.common.Field) Function(com.google.common.base.Function) ArrayList(java.util.ArrayList) OutputField(org.jpmml.evaluator.OutputField) FieldName(org.dmg.pmml.FieldName)

Example 2 with OutputField

use of org.jpmml.evaluator.OutputField 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;
}
Also used : HasGroupFields(org.jpmml.evaluator.HasGroupFields) InputField(org.jpmml.evaluator.InputField) OutputField(org.jpmml.evaluator.OutputField) ArrayList(java.util.ArrayList) List(java.util.List) TargetField(org.jpmml.evaluator.TargetField) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)2 InputField (org.jpmml.evaluator.InputField)2 OutputField (org.jpmml.evaluator.OutputField)2 TargetField (org.jpmml.evaluator.TargetField)2 Function (com.google.common.base.Function)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 DataField (org.dmg.pmml.DataField)1 FieldName (org.dmg.pmml.FieldName)1 HasGroupFields (org.jpmml.evaluator.HasGroupFields)1 Field (org.openscoring.common.Field)1