Java Code Examples for org.dmg.pmml.FieldRef#getField()
The following examples show how to use
org.dmg.pmml.FieldRef#getField() .
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: FormulaUtil.java From jpmml-r with GNU Affero General Public License v3.0 | 6 votes |
static private FieldName prepareInputField(FunctionExpression.Argument argument, OpType opType, DataType dataType, RExpEncoder encoder){ Expression expression = argument.getExpression(); if(expression instanceof FieldRef){ FieldRef fieldRef = (FieldRef)expression; return fieldRef.getField(); } else if(expression instanceof Apply){ Apply apply = (Apply)expression; DerivedField derivedField = encoder.createDerivedField(FieldName.create((argument.formatExpression()).trim()), opType, dataType, apply); return derivedField.getName(); } else { throw new IllegalArgumentException(); } }
Example 2
Source File: Formula.java From jpmml-r with GNU Affero General Public License v3.0 | 5 votes |
public void addField(Field<?> field){ RExpEncoder encoder = getEncoder(); Feature feature = new ContinuousFeature(encoder, field); if(field instanceof DerivedField){ DerivedField derivedField = (DerivedField)field; Expression expression = derivedField.getExpression(); if(expression instanceof Apply){ Apply apply = (Apply)expression; if(checkApply(apply, PMMLFunctions.POW, FieldRef.class, Constant.class)){ List<Expression> expressions = apply.getExpressions(); FieldRef fieldRef = (FieldRef)expressions.get(0); Constant constant = (Constant)expressions.get(1); try { String string = ValueUtil.asString(constant.getValue()); int power = Integer.parseInt(string); feature = new PowerFeature(encoder, fieldRef.getField(), DataType.DOUBLE, power); } catch(NumberFormatException nfe){ // Ignored } } } } putFeature(field.getName(), feature); this.fields.add(field); }
Example 3
Source File: NeuralNetworkEvaluator.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 5 votes |
private Expression getOutputExpression(NeuralOutput neuralOutput){ DerivedField derivedField = neuralOutput.getDerivedField(); if(derivedField == null){ throw new MissingElementException(neuralOutput, PMMLElements.NEURALOUTPUT_DERIVEDFIELD); } Expression expression = ExpressionUtil.ensureExpression(derivedField); if(expression instanceof FieldRef){ FieldRef fieldRef = (FieldRef)expression; FieldName name = fieldRef.getField(); if(name == null){ throw new MissingAttributeException(fieldRef, org.dmg.pmml.PMMLAttributes.FIELDREF_FIELD); } Field<?> field = resolveField(name); if(field == null){ throw new MissingFieldException(name, fieldRef); } // End if if(field instanceof DataField){ return expression; } else if(field instanceof DerivedField){ DerivedField targetDerivedField = (DerivedField)field; Expression targetExpression = ExpressionUtil.ensureExpression(targetDerivedField); return targetExpression; } else { throw new InvalidAttributeException(fieldRef, org.dmg.pmml.PMMLAttributes.FIELDREF_FIELD, name); } } return expression; }