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);
}
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));
}
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);
}
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);
}
Aggregations