use of org.kie.pmml.commons.model.KiePMMLTarget in project drools by kiegroup.
the class KiePMMLTargetInstanceFactory method getKiePMMLTarget.
public static KiePMMLTarget getKiePMMLTarget(final Target target) {
final List<TargetValue> targetValues = target.hasTargetValues() ? target.getTargetValues().stream().map(KiePMMLTargetInstanceFactory::getKieTargetValue).collect(Collectors.toList()) : Collections.emptyList();
final OP_TYPE opType = target.getOpType() != null ? OP_TYPE.byName(target.getOpType().value()) : null;
final String field = target.getField() != null ? target.getField().getValue() : null;
final CAST_INTEGER castInteger = target.getCastInteger() != null ? CAST_INTEGER.byName(target.getCastInteger().value()) : null;
TargetField targetField = new TargetField(targetValues, opType, field, castInteger, target.getMin(), target.getMax(), target.getRescaleConstant(), target.getRescaleFactor());
final KiePMMLTarget.Builder builder = KiePMMLTarget.builder(targetField.getName(), Collections.emptyList(), targetField);
return builder.build();
}
use of org.kie.pmml.commons.model.KiePMMLTarget in project drools by kiegroup.
the class KiePMMLTargetInstanceFactoryTest method getKiePMMLTarget.
@Test
public void getKiePMMLTarget() {
final Target toConvert = getRandomTarget();
KiePMMLTarget retrieved = KiePMMLTargetInstanceFactory.getKiePMMLTarget(toConvert);
commonVerifyKiePMMLTarget(retrieved, toConvert);
}
use of org.kie.pmml.commons.model.KiePMMLTarget in project drools by kiegroup.
the class PostProcessTest method executeTargets.
@Test
public void executeTargets() {
// Build model
String TARGET_NAME = "TARGET_NAME";
String FIELD_NAME = "FIELD_NAME";
TargetField targetField = new TargetField(Collections.emptyList(), null, FIELD_NAME, null, 4.34, null, null, null);
KiePMMLTarget kiePMMLTarget = KiePMMLTarget.builder(TARGET_NAME, Collections.emptyList(), targetField).build();
List<KiePMMLTarget> kiePMMLTargets = Arrays.asList(kiePMMLTarget, KiePMMLTarget.builder("NEW_TARGET", Collections.emptyList(), new TargetField(Collections.emptyList(), null, "NEW_TARGET", null, null, null, null, null)).build());
KiePMMLTestingModel model = KiePMMLTestingModel.builder("TESTINGMODEL", Collections.emptyList(), MINING_FUNCTION.REGRESSION).withKiePMMLTargets(kiePMMLTargets).build();
// Build PMML4Result
PMML4Result toModify = new PMML4Result();
toModify.setResultCode(ResultCode.FAIL.getName());
toModify.addResultVariable(FIELD_NAME, 4.33);
assertEquals(4.33, toModify.getResultVariables().get(FIELD_NAME));
ProcessingDTO processingDTO = getProcessingDTO(model, new ArrayList<>());
PostProcess.executeTargets(toModify, processingDTO);
assertEquals(4.33, toModify.getResultVariables().get(FIELD_NAME));
toModify.setResultCode(ResultCode.OK.getName());
PostProcess.executeTargets(toModify, processingDTO);
assertEquals(4.33, toModify.getResultVariables().get(FIELD_NAME));
toModify.setResultObjectName(FIELD_NAME);
PostProcess.executeTargets(toModify, processingDTO);
assertEquals(4.34, toModify.getResultVariables().get(FIELD_NAME));
}
Aggregations