use of org.kie.pmml.api.enums.OUTLIER_TREATMENT_METHOD in project drools by kiegroup.
the class KiePMMLNormContinuousFactory method getNormContinuousVariableDeclaration.
static BlockStmt getNormContinuousVariableDeclaration(final String variableName, final NormContinuous normContinuous) {
final MethodDeclaration methodDeclaration = NORMCONTINUOUS_TEMPLATE.getMethodsByName(GETKIEPMMLNORMCONTINUOUS).get(0).clone();
final BlockStmt toReturn = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration)));
final VariableDeclarator variableDeclarator = getVariableDeclarator(toReturn, NORM_CONTINUOUS).orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_IN_BODY, NORM_CONTINUOUS, toReturn)));
variableDeclarator.setName(variableName);
final ObjectCreationExpr objectCreationExpr = variableDeclarator.getInitializer().orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_INITIALIZER_TEMPLATE, NORM_CONTINUOUS, toReturn))).asObjectCreationExpr();
final StringLiteralExpr nameExpr = new StringLiteralExpr(normContinuous.getField().getValue());
final OUTLIER_TREATMENT_METHOD outlierTreatmentMethod = OUTLIER_TREATMENT_METHOD.byName(normContinuous.getOutliers().value());
final NameExpr outlierTreatmentMethodExpr = new NameExpr(OUTLIER_TREATMENT_METHOD.class.getName() + "." + outlierTreatmentMethod.name());
NodeList<Expression> arguments = new NodeList<>();
int counter = 0;
for (LinearNorm linearNorm : normContinuous.getLinearNorms()) {
arguments.add(getNewKiePMMLLinearNormExpression(linearNorm, "LinearNorm-" + counter));
}
final Expression mapMissingToExpr = getExpressionForObject(normContinuous.getMapMissingTo());
objectCreationExpr.getArguments().set(0, nameExpr);
objectCreationExpr.getArguments().get(2).asMethodCallExpr().setArguments(arguments);
objectCreationExpr.getArguments().set(3, outlierTreatmentMethodExpr);
objectCreationExpr.getArguments().set(4, mapMissingToExpr);
return toReturn;
}
use of org.kie.pmml.api.enums.OUTLIER_TREATMENT_METHOD in project drools by kiegroup.
the class KiePMMLNormContinuousInstanceFactory method getKiePMMLNormContinuous.
static KiePMMLNormContinuous getKiePMMLNormContinuous(final NormContinuous normContinuous) {
final List<KiePMMLLinearNorm> linearNorms = normContinuous.hasLinearNorms() ? getKiePMMLLinearNorms(normContinuous.getLinearNorms()) : Collections.emptyList();
final OUTLIER_TREATMENT_METHOD outlierTreatmentMethod = normContinuous.getOutliers() != null ? OUTLIER_TREATMENT_METHOD.byName(normContinuous.getOutliers().value()) : null;
return new KiePMMLNormContinuous(normContinuous.getField().getValue(), getKiePMMLExtensions(normContinuous.getExtensions()), linearNorms, outlierTreatmentMethod, normContinuous.getMapMissingTo());
}
Aggregations