Search in sources :

Example 6 with INVALID_VALUE_TREATMENT_METHOD

use of org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD in project drools by kiegroup.

the class ModelUtils method convertToKieMiningField.

/**
 * Return a <code>org.kie.pmml.api.models.MiningField</code> out of a <code>org.dmg.pmml.MiningField</code> and
 * relative <code>org.dmg.pmml.DataField</code> ones
 * @param toConvert
 * @param field
 * @return
 */
public static org.kie.pmml.api.models.MiningField convertToKieMiningField(final MiningField toConvert, final Field<?> field) {
    final String name = toConvert.getName() != null ? toConvert.getName().getValue() : null;
    final FIELD_USAGE_TYPE fieldUsageType = toConvert.getUsageType() != null ? FIELD_USAGE_TYPE.byName(toConvert.getUsageType().value()) : null;
    final OP_TYPE opType = toConvert.getOpType() != null ? OP_TYPE.byName(toConvert.getOpType().value()) : null;
    final DATA_TYPE dataType = field.getDataType() != null ? DATA_TYPE.byName(field.getDataType().value()) : null;
    final MISSING_VALUE_TREATMENT_METHOD missingValueTreatmentMethod = toConvert.getMissingValueTreatment() != null ? MISSING_VALUE_TREATMENT_METHOD.byName(toConvert.getMissingValueTreatment().value()) : null;
    final INVALID_VALUE_TREATMENT_METHOD invalidValueTreatmentMethod = toConvert.getInvalidValueTreatment() != null ? INVALID_VALUE_TREATMENT_METHOD.byName(toConvert.getInvalidValueTreatment().value()) : null;
    final String missingValueReplacement = toConvert.getMissingValueReplacement() != null ? toConvert.getMissingValueReplacement().toString() : null;
    final String invalidValueReplacement = toConvert.getInvalidValueReplacement() != null ? toConvert.getInvalidValueReplacement().toString() : null;
    final List<String> allowedValues = field instanceof DataField ? convertDataFieldValues(((DataField) field).getValues()) : Collections.emptyList();
    final List<org.kie.pmml.api.models.Interval> intervals = field instanceof DataField ? convertDataFieldIntervals(((DataField) field).getIntervals()) : Collections.emptyList();
    return new org.kie.pmml.api.models.MiningField(name, fieldUsageType, opType, dataType, missingValueTreatmentMethod, invalidValueTreatmentMethod, missingValueReplacement, invalidValueReplacement, allowedValues, intervals);
}
Also used : MiningField(org.dmg.pmml.MiningField) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) INVALID_VALUE_TREATMENT_METHOD(org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD) MISSING_VALUE_TREATMENT_METHOD(org.kie.pmml.api.enums.MISSING_VALUE_TREATMENT_METHOD) FIELD_USAGE_TYPE(org.kie.pmml.api.enums.FIELD_USAGE_TYPE) DataField(org.dmg.pmml.DataField) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) Interval(org.dmg.pmml.Interval)

Aggregations

INVALID_VALUE_TREATMENT_METHOD (org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD)6 DataField (org.dmg.pmml.DataField)3 DATA_TYPE (org.kie.pmml.api.enums.DATA_TYPE)3 FIELD_USAGE_TYPE (org.kie.pmml.api.enums.FIELD_USAGE_TYPE)3 MISSING_VALUE_TREATMENT_METHOD (org.kie.pmml.api.enums.MISSING_VALUE_TREATMENT_METHOD)3 OP_TYPE (org.kie.pmml.api.enums.OP_TYPE)3 MiningField (org.dmg.pmml.MiningField)2 Test (org.junit.Test)2 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)2 Interval (org.kie.pmml.api.models.Interval)2 MiningField (org.kie.pmml.api.models.MiningField)2 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)1 Expression (com.github.javaparser.ast.expr.Expression)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1 NameExpr (com.github.javaparser.ast.expr.NameExpr)1 NullLiteralExpr (com.github.javaparser.ast.expr.NullLiteralExpr)1 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 DataType (org.dmg.pmml.DataType)1