org.dmg.pmml.FieldColumnPair Java Examples
The following examples show how to use
org.dmg.pmml.FieldColumnPair.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpressionUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
static public FieldValue evaluateMapValues(MapValues mapValues, EvaluationContext context){ Map<String, FieldValue> values = new LinkedHashMap<>(); List<FieldColumnPair> fieldColumnPairs = mapValues.getFieldColumnPairs(); for(FieldColumnPair fieldColumnPair : fieldColumnPairs){ FieldName name = fieldColumnPair.getField(); if(name == null){ throw new MissingAttributeException(fieldColumnPair, PMMLAttributes.FIELDCOLUMNPAIR_FIELD); } String column = fieldColumnPair.getColumn(); if(column == null){ throw new MissingAttributeException(fieldColumnPair, PMMLAttributes.FIELDCOLUMNPAIR_COLUMN); } FieldValue value = context.evaluate(name); if(FieldValueUtil.isMissing(value)){ return FieldValueUtil.create(mapValues.getDataType(DataType.STRING), OpType.CATEGORICAL, mapValues.getMapMissingTo()); } values.put(column, value); } return DiscretizationUtil.mapValue(mapValues, values); }
Example #2
Source File: ExpressionUtilTest.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
@Test public void evaluateMapValues(){ FieldName name = FieldName.create("x"); List<List<String>> rows = Arrays.asList( Arrays.asList("0", "zero"), Arrays.asList("1", "one") ); MapValues mapValues = new MapValues("data:output", null, createInlineTable(rows, Arrays.asList("data:input", "data:output"))) .addFieldColumnPairs(new FieldColumnPair(name, "data:input")); assertEquals("zero", evaluate(mapValues, name, "0")); assertEquals("one", evaluate(mapValues, name, "1")); assertEquals(null, evaluate(mapValues, name, "3")); assertEquals(null, evaluate(mapValues, name, null)); mapValues.setMapMissingTo("Missing"); assertEquals("Missing", evaluate(mapValues, name, null)); mapValues.setDefaultValue("Default"); assertEquals("Default", evaluate(mapValues, name, "3")); }
Example #3
Source File: FieldReferenceFinder.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public VisitorAction visit(FieldColumnPair fieldColumnPair){ process(fieldColumnPair.getField()); return super.visit(fieldColumnPair); }