use of org.jpmml.converter.PowerFeature in project jpmml-r by jpmml.
the class Formula method addField.
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, "pow", FieldRef.class, Constant.class)) {
List<Expression> expressions = apply.getExpressions();
FieldRef fieldRef = (FieldRef) expressions.get(0);
Constant constant = (Constant) expressions.get(1);
try {
int power = Integer.parseInt(constant.getValue());
feature = new PowerFeature(encoder, fieldRef.getField(), DataType.DOUBLE, power);
} catch (NumberFormatException nfe) {
// Ignored
}
}
}
}
putFeature(field.getName(), feature);
this.fields.add(field);
}
Aggregations