Search in sources :

Example 1 with False

use of org.dmg.pmml.False in project drools by kiegroup.

the class KiePMMLFalsePredicateInstanceFactoryTest method getKiePMMLFalsePredicate.

@Test
public void getKiePMMLFalsePredicate() {
    False toConvert = new False();
    KiePMMLFalsePredicate retrieved = KiePMMLFalsePredicateInstanceFactory.getKiePMMLFalsePredicate(toConvert);
    commonVerifyKiePMMLFalsePredicate(retrieved, toConvert);
}
Also used : InstanceFactoriesTestCommon.commonVerifyKiePMMLFalsePredicate(org.kie.pmml.compiler.commons.factories.InstanceFactoriesTestCommon.commonVerifyKiePMMLFalsePredicate) KiePMMLFalsePredicate(org.kie.pmml.commons.model.predicates.KiePMMLFalsePredicate) False(org.dmg.pmml.False) Test(org.junit.Test)

Example 2 with False

use of org.dmg.pmml.False in project drools by kiegroup.

the class KiePMMLTreeModelNodeASTFactory method declareFinalRuleFromNode.

/**
 * This method is meant to be executed when <code>node</code> <b>is</b> a <i>final leaf</i>
 * @param node
 * @param parentPath
 * @param rules
 */
protected void declareFinalRuleFromNode(final Node node, final String parentPath, final List<KiePMMLDroolsRule> rules) {
    logger.trace("declareFinalRuleFromNode {} {}", node, parentPath);
    final Predicate predicate = node.getPredicate();
    // an XOR compound predicate
    if (predicate instanceof False) {
        return;
    }
    String currentRule = String.format(PATH_PATTERN, parentPath, node.hashCode());
    PredicateASTFactoryData predicateASTFactoryData = new PredicateASTFactoryData(predicate, outputFields, rules, parentPath, currentRule, fieldTypeMap);
    KiePMMLPredicateASTFactory.factory(predicateASTFactoryData).declareRuleFromPredicate(getCorrectlyFormattedResult(node.getScore(), targetType), true);
}
Also used : False(org.dmg.pmml.False) PredicateASTFactoryData(org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData) Predicate(org.dmg.pmml.Predicate)

Example 3 with False

use of org.dmg.pmml.False in project drools by kiegroup.

the class KiePMMLTreeModelNodeASTFactory method declareIntermediateRuleFromNode.

/**
 * This method is meant to be executed when <code>node</code> <b>is not</b> a <i>final leaf</i>
 * @param node
 * @param parentPath
 * @param rules
 */
protected void declareIntermediateRuleFromNode(final Node node, final String parentPath, final List<KiePMMLDroolsRule> rules) {
    logger.trace("declareIntermediateRuleFromNode {} {}", node, parentPath);
    final Predicate predicate = node.getPredicate();
    // an XOR compound predicate
    if (predicate instanceof False) {
        return;
    }
    String currentRule = String.format(PATH_PATTERN, parentPath, node.hashCode());
    PredicateASTFactoryData predicateASTFactoryData = new PredicateASTFactoryData(predicate, outputFields, rules, parentPath, currentRule, fieldTypeMap);
    KiePMMLPredicateASTFactory.factory(predicateASTFactoryData).declareRuleFromPredicate(getCorrectlyFormattedResult(node.getScore(), targetType), false);
    node.getNodes().forEach(child -> declareRuleFromNode(child, currentRule, rules));
}
Also used : False(org.dmg.pmml.False) PredicateASTFactoryData(org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData) Predicate(org.dmg.pmml.Predicate)

Example 4 with False

use of org.dmg.pmml.False in project drools by kiegroup.

the class KiePMMLScorecardModelCharacteristicASTFactory method declareRuleFromAttribute.

protected void declareRuleFromAttribute(final Attribute attribute, final String parentPath, final int attributeIndex, final List<KiePMMLDroolsRule> rules, final String statusToSet, final String characteristicReasonCode, final Number characteristicBaselineScore, final boolean isLastCharacteristic) {
    logger.trace("declareRuleFromAttribute {} {}", attribute, parentPath);
    final Predicate predicate = attribute.getPredicate();
    // an XOR compound predicate
    if (predicate instanceof False) {
        return;
    }
    String currentRule = String.format(PATH_PATTERN, parentPath, attributeIndex);
    KiePMMLReasonCodeAndValue reasonCodeAndValue = getKiePMMLReasonCodeAndValue(attribute, characteristicReasonCode, characteristicBaselineScore);
    PredicateASTFactoryData predicateASTFactoryData = new PredicateASTFactoryData(predicate, outputFields, rules, parentPath, currentRule, fieldTypeMap);
    KiePMMLPredicateASTFactory.factory(predicateASTFactoryData).declareRuleFromPredicate(attribute.getPartialScore(), statusToSet, reasonCodeAndValue, isLastCharacteristic);
}
Also used : KiePMMLReasonCodeAndValue(org.kie.pmml.models.drools.tuples.KiePMMLReasonCodeAndValue) False(org.dmg.pmml.False) PredicateASTFactoryData(org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData) Predicate(org.dmg.pmml.Predicate)

Example 5 with False

use of org.dmg.pmml.False in project drools by kiegroup.

the class KiePMMLFalsePredicateFactoryTest method getFalsePredicateVariableDeclaration.

@Test
public void getFalsePredicateVariableDeclaration() throws IOException {
    String variableName = "variableName";
    BlockStmt retrieved = KiePMMLFalsePredicateFactory.getFalsePredicateVariableDeclaration(variableName, new False());
    String text = getFileContent(TEST_01_SOURCE);
    Statement expected = JavaParserUtils.parseBlock(String.format(text, variableName));
    assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
    List<Class<?>> imports = Arrays.asList(KiePMMLFalsePredicate.class, Collections.class);
    commonValidateCompilationWithImports(retrieved, imports);
}
Also used : Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) False(org.dmg.pmml.False) Test(org.junit.Test)

Aggregations

False (org.dmg.pmml.False)6 Predicate (org.dmg.pmml.Predicate)3 Test (org.junit.Test)3 PredicateASTFactoryData (org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData)3 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 Statement (com.github.javaparser.ast.stmt.Statement)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 CompoundPredicate (org.dmg.pmml.CompoundPredicate)1 DataField (org.dmg.pmml.DataField)1 Field (org.dmg.pmml.Field)1 SimplePredicate (org.dmg.pmml.SimplePredicate)1 SimpleSetPredicate (org.dmg.pmml.SimpleSetPredicate)1 True (org.dmg.pmml.True)1 KiePMMLFalsePredicate (org.kie.pmml.commons.model.predicates.KiePMMLFalsePredicate)1 KiePMMLPredicate (org.kie.pmml.commons.model.predicates.KiePMMLPredicate)1 PMMLModelTestUtils.getRandomCompoundPredicate (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomCompoundPredicate)1 PMMLModelTestUtils.getRandomDataField (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomDataField)1 PMMLModelTestUtils.getRandomSimplePredicate (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomSimplePredicate)1