use of org.dmg.pmml.scorecard.Attribute in project drools by kiegroup.
the class KiePMMLScorecardModelCharacteristicASTFactoryTest method declareRuleFromAttributeWithSimplePredicateUseReasonCodesTrue.
@Test
public void declareRuleFromAttributeWithSimplePredicateUseReasonCodesTrue() {
Attribute attribute = getSimplePredicateAttribute();
final String parentPath = "parent_path";
final int attributeIndex = 2;
final List<KiePMMLDroolsRule> rules = new ArrayList<>();
final String statusToSet = "status_to_set";
final String characteristicReasonCode = "REASON_CODE";
final double characteristicBaselineScore = 12;
final boolean isLastCharacteristic = false;
getKiePMMLScorecardModelCharacteristicASTFactory().withReasonCodes(null, REASONCODE_ALGORITHM.POINTS_ABOVE).declareRuleFromAttribute(attribute, parentPath, attributeIndex, rules, statusToSet, characteristicReasonCode, characteristicBaselineScore, isLastCharacteristic);
assertEquals(1, rules.size());
KiePMMLDroolsRule toValidate = rules.get(0);
commonValidateRule(toValidate, attribute, statusToSet, parentPath, attributeIndex, isLastCharacteristic, 1, null, BOOLEAN_OPERATOR.AND, "value <= 5.0", 1);
KiePMMLReasonCodeAndValue retrieved = toValidate.getReasonCodeAndValue();
assertNotNull(retrieved);
assertEquals(characteristicReasonCode, retrieved.getReasonCode());
double expected = attribute.getPartialScore().doubleValue() - characteristicBaselineScore;
assertEquals(expected, retrieved.getValue(), 0);
}
use of org.dmg.pmml.scorecard.Attribute in project drools by kiegroup.
the class KiePMMLScorecardModelCharacteristicASTFactoryTest method declareRuleFromAttributeWithSimpleSetPredicate.
@Test
public void declareRuleFromAttributeWithSimpleSetPredicate() {
Attribute attribute = getSimpleSetPredicateAttribute();
final String parentPath = "parent_path";
final int attributeIndex = 2;
final List<KiePMMLDroolsRule> rules = new ArrayList<>();
final String statusToSet = "status_to_set";
final String characteristicReasonCode = "REASON_CODE";
final double characteristicBaselineScore = 12;
final boolean isLastCharacteristic = false;
getKiePMMLScorecardModelCharacteristicASTFactory().declareRuleFromAttribute(attribute, parentPath, attributeIndex, rules, statusToSet, characteristicReasonCode, characteristicBaselineScore, isLastCharacteristic);
assertEquals(1, rules.size());
commonValidateRule(rules.get(0), attribute, statusToSet, parentPath, attributeIndex, isLastCharacteristic, null, 1, null, null, null);
}
use of org.dmg.pmml.scorecard.Attribute in project drools by kiegroup.
the class KiePMMLScorecardModelCharacteristicASTFactoryTest method declareRuleFromAttributeWithCompoundPredicate.
@Test
public void declareRuleFromAttributeWithCompoundPredicate() {
Attribute attribute = getCompoundPredicateAttribute();
final String parentPath = "parent_path";
final int attributeIndex = 2;
final List<KiePMMLDroolsRule> rules = new ArrayList<>();
final String statusToSet = "status_to_set";
final String characteristicReasonCode = "REASON_CODE";
final double characteristicBaselineScore = 12;
final boolean isLastCharacteristic = false;
getKiePMMLScorecardModelCharacteristicASTFactory().declareRuleFromAttribute(attribute, parentPath, attributeIndex, rules, statusToSet, characteristicReasonCode, characteristicBaselineScore, isLastCharacteristic);
assertEquals(1, rules.size());
commonValidateRule(rules.get(0), attribute, statusToSet, parentPath, attributeIndex, isLastCharacteristic, 1, null, BOOLEAN_OPERATOR.AND, "value >= 5.0 && value < 12.0", 2);
}
use of org.dmg.pmml.scorecard.Attribute in project drools by kiegroup.
the class KiePMMLScorecardModelCharacteristicASTFactoryTest method declareRuleFromAttributeWithSimplePredicateNotLastCharacteristic.
@Test
public void declareRuleFromAttributeWithSimplePredicateNotLastCharacteristic() {
Attribute attribute = getSimplePredicateAttribute();
final String parentPath = "parent_path";
final int attributeIndex = 2;
final List<KiePMMLDroolsRule> rules = new ArrayList<>();
final String statusToSet = "status_to_set";
final String characteristicReasonCode = "REASON_CODE";
final double characteristicBaselineScore = 12;
final boolean isLastCharacteristic = false;
getKiePMMLScorecardModelCharacteristicASTFactory().declareRuleFromAttribute(attribute, parentPath, attributeIndex, rules, statusToSet, characteristicReasonCode, characteristicBaselineScore, isLastCharacteristic);
assertEquals(1, rules.size());
commonValidateRule(rules.get(0), attribute, statusToSet, parentPath, attributeIndex, isLastCharacteristic, 1, null, BOOLEAN_OPERATOR.AND, "value <= 5.0", 1);
}
use of org.dmg.pmml.scorecard.Attribute in project drools by kiegroup.
the class KiePMMLCharacteristicFactoryTest method getAttribute.
private Attribute getAttribute(List<String> values, int id) {
Attribute toReturn = new Attribute();
toReturn.setReasonCode(REASON_CODE + id);
Array.Type arrayType = Array.Type.STRING;
toReturn.setPredicate(getCompoundPredicate(values, arrayType));
toReturn.setComplexPartialScore(getComplexPartialScore());
return toReturn;
}
Aggregations