use of org.dmg.pmml.Constant in project jpmml-r by jpmml.
the class ExpressionCompactorTest method compactNegationExpression.
@Test
public void compactNegationExpression() {
FieldRef fieldRef = new FieldRef(FieldName.create("x"));
Constant constant = createConstant("0");
Apply apply = compact(createApply("not", createApply("equal", fieldRef, constant)));
assertEquals("notEqual", apply.getFunction());
assertEquals(Arrays.asList(fieldRef, constant), apply.getExpressions());
apply = compact(createApply("not", createApply("isMissing", fieldRef)));
assertEquals("isNotMissing", apply.getFunction());
assertEquals(Arrays.asList(fieldRef), apply.getExpressions());
}
use of org.dmg.pmml.Constant in project jpmml-sparkml by jpmml.
the class TermFeature method createApply.
public Apply createApply() {
DefineFunction defineFunction = getDefineFunction();
Feature feature = getFeature();
String value = getValue();
Constant constant = PMMLUtil.createConstant(value, DataType.STRING);
return PMMLUtil.createApply(defineFunction.getName(), feature.ref(), constant);
}
use of org.dmg.pmml.Constant in project shifu by ShifuML.
the class NeuralNetworkModelIntegrator method getLocalTranformations.
private LocalTransformations getLocalTranformations(NeuralNetwork model) {
// delete target
List<DerivedField> derivedFields = model.getLocalTransformations().getDerivedFields();
// add bias
DerivedField field = new DerivedField(OpType.CONTINUOUS, DataType.DOUBLE).setName(new FieldName(PluginConstants.biasValue));
field.setExpression(new Constant(String.valueOf(PluginConstants.bias)));
derivedFields.add(field);
return new LocalTransformations().addDerivedFields(derivedFields.toArray(new DerivedField[derivedFields.size()]));
}
use of org.dmg.pmml.Constant in project drools by kiegroup.
the class PMMLModelTestUtils method getRandomConstant.
public static Constant getRandomConstant() {
Constant toReturn = new Constant();
toReturn.setDataType(getRandomDataType());
toReturn.setValue(getRandomObject(toReturn.getDataType()));
return toReturn;
}
use of org.dmg.pmml.Constant in project drools by kiegroup.
the class PMMLModelTestUtils method getDefineFunction.
public static DefineFunction getDefineFunction(String functionName) {
DefineFunction toReturn = new DefineFunction();
toReturn.setName(functionName);
toReturn.setDataType(getRandomDataType());
toReturn.setOpType(getRandomOpType());
Constant expression = new Constant(5);
expression.setDataType(DataType.INTEGER);
toReturn.setExpression(expression);
IntStream.range(0, 3).forEach(i -> toReturn.addParameterFields(getParameterField("ParameterField-" + i)));
return toReturn;
}
Aggregations