Search in sources :

Example 1 with Constant

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());
}
Also used : FieldRef(org.dmg.pmml.FieldRef) Constant(org.dmg.pmml.Constant) Apply(org.dmg.pmml.Apply) Test(org.junit.Test)

Example 2 with Constant

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);
}
Also used : Constant(org.dmg.pmml.Constant) DefineFunction(org.dmg.pmml.DefineFunction) Feature(org.jpmml.converter.Feature) ContinuousFeature(org.jpmml.converter.ContinuousFeature)

Example 3 with 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()]));
}
Also used : LocalTransformations(org.dmg.pmml.LocalTransformations) Constant(org.dmg.pmml.Constant) DerivedField(org.dmg.pmml.DerivedField) FieldName(org.dmg.pmml.FieldName)

Example 4 with Constant

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;
}
Also used : Constant(org.dmg.pmml.Constant)

Example 5 with Constant

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;
}
Also used : Constant(org.dmg.pmml.Constant) DefineFunction(org.dmg.pmml.DefineFunction)

Aggregations

Constant (org.dmg.pmml.Constant)23 KiePMMLConstant (org.kie.pmml.commons.model.expressions.KiePMMLConstant)13 Test (org.junit.Test)10 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)7 Statement (com.github.javaparser.ast.stmt.Statement)7 Apply (org.dmg.pmml.Apply)7 DerivedField (org.dmg.pmml.DerivedField)7 FieldRef (org.dmg.pmml.FieldRef)6 KiePMMLApply (org.kie.pmml.commons.model.expressions.KiePMMLApply)5 DefineFunction (org.dmg.pmml.DefineFunction)4 ComplexPartialScore (org.dmg.pmml.scorecard.ComplexPartialScore)4 KiePMMLFieldRef (org.kie.pmml.commons.model.expressions.KiePMMLFieldRef)4 KiePMMLDerivedField (org.kie.pmml.commons.transformations.KiePMMLDerivedField)4 KiePMMLComplexPartialScore (org.kie.pmml.models.scorecard.model.KiePMMLComplexPartialScore)4 CommonTestingUtils.getDATA_TYPEString (org.kie.pmml.compiler.api.CommonTestingUtils.getDATA_TYPEString)3 CommonTestingUtils.getOP_TYPEString (org.kie.pmml.compiler.api.CommonTestingUtils.getOP_TYPEString)3 Expression (org.dmg.pmml.Expression)2 ParameterField (org.dmg.pmml.ParameterField)2 ContinuousFeature (org.jpmml.converter.ContinuousFeature)2 Feature (org.jpmml.converter.Feature)2