Search in sources :

Example 1 with Field

use of org.openscoring.common.Field 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;
}
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) DataField(org.dmg.pmml.DataField) ArrayList(java.util.ArrayList) TargetField(org.jpmml.evaluator.TargetField) FieldName(org.dmg.pmml.FieldName)

Example 2 with Field

use of org.openscoring.common.Field 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 3 with Field

use of org.openscoring.common.Field in project openscoring by openscoring.

the class ModelUtil method encodeInputFields.

private static List<Field> encodeInputFields(List<InputField> inputFields) {
    Function<InputField, Field> function = new Function<InputField, Field>() {

        @Override
        public Field apply(InputField inputField) {
            FieldName name = inputField.getName();
            DataField dataField = (DataField) inputField.getField();
            Field field = new Field(name.getValue());
            field.setName(dataField.getDisplayName());
            field.setDataType(inputField.getDataType());
            field.setOpType(inputField.getOpType());
            field.setValues(encodeValues(dataField));
            return field;
        }
    };
    List<Field> fields = new ArrayList<>(Lists.transform(inputFields, 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) InputField(org.jpmml.evaluator.InputField) DataField(org.dmg.pmml.DataField) ArrayList(java.util.ArrayList) FieldName(org.dmg.pmml.FieldName)

Aggregations

Function (com.google.common.base.Function)3 ArrayList (java.util.ArrayList)3 DataField (org.dmg.pmml.DataField)3 FieldName (org.dmg.pmml.FieldName)3 InputField (org.jpmml.evaluator.InputField)3 OutputField (org.jpmml.evaluator.OutputField)3 TargetField (org.jpmml.evaluator.TargetField)3 Field (org.openscoring.common.Field)3