Search in sources :

Example 1 with PredicateASTFactoryData

use of org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData 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 2 with PredicateASTFactoryData

use of org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData 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 3 with PredicateASTFactoryData

use of org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData 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 4 with PredicateASTFactoryData

use of org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData in project drools by kiegroup.

the class KiePMMLTreeModelNodeASTFactory method declareDefaultRuleFromNode.

/**
 * This method is meant to be executed when <b>noTrueChildStrategy</b> is <code>TreeModel.NoTrueChildStrategy.RETURN_LAST_PREDICTION</code>, <b>node</b>
 * is not a <i>final leaf</i>, and <b>node</b>'s score is not null
 * @param node
 * @param parentPath
 * @param rules
 */
protected void declareDefaultRuleFromNode(final Node node, final String parentPath, final List<KiePMMLDroolsRule> rules) {
    logger.trace("declareDefaultRuleFromNode {} {}", node, parentPath);
    String originalRule = String.format(PATH_PATTERN, parentPath, node.hashCode());
    String currentRule = String.format(PATH_PATTERN, "default", originalRule);
    PredicateASTFactoryData predicateASTFactoryData = new PredicateASTFactoryData(new True(), outputFields, rules, originalRule, currentRule, fieldTypeMap);
    KiePMMLPredicateASTFactory.factory(predicateASTFactoryData).declareRuleFromPredicate(getCorrectlyFormattedResult(node.getScore(), targetType), true);
}
Also used : True(org.dmg.pmml.True) PredicateASTFactoryData(org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData)

Aggregations

PredicateASTFactoryData (org.kie.pmml.models.drools.ast.factories.PredicateASTFactoryData)4 False (org.dmg.pmml.False)3 Predicate (org.dmg.pmml.Predicate)3 True (org.dmg.pmml.True)1 KiePMMLReasonCodeAndValue (org.kie.pmml.models.drools.tuples.KiePMMLReasonCodeAndValue)1