Search in sources :

Example 1 with PMMLSetOperator

use of org.knime.base.node.mine.decisiontree2.PMMLSetOperator in project knime-core by knime.

the class TreeModelPMMLTranslator method setValuesFromPMMLSimpleSetPredicate.

private static void setValuesFromPMMLSimpleSetPredicate(final SimpleSetPredicate to, final PMMLSimpleSetPredicate from) {
    to.setField(from.getSplitAttribute());
    final Enum operator;
    final PMMLSetOperator setOp = from.getSetOperator();
    switch(setOp) {
        case IS_IN:
            operator = SimpleSetPredicate.BooleanOperator.IS_IN;
            break;
        case IS_NOT_IN:
            operator = SimpleSetPredicate.BooleanOperator.IS_NOT_IN;
            break;
        default:
            throw new IllegalStateException("Unknown set operator \"" + setOp + "\".");
    }
    to.setBooleanOperator(operator);
    final Set<String> values = from.getValues();
    ArrayType array = to.addNewArray();
    array.setN(BigInteger.valueOf(values.size()));
    org.w3c.dom.Node arrayNode = array.getDomNode();
    arrayNode.appendChild(arrayNode.getOwnerDocument().createTextNode(setToWhitspaceSeparatedString(values)));
    final org.dmg.pmml.ArrayType.Type.Enum type;
    final PMMLArrayType arrayType = from.getArrayType();
    switch(arrayType) {
        case INT:
            type = ArrayType.Type.INT;
            break;
        case REAL:
            type = ArrayType.Type.REAL;
            break;
        case STRING:
            type = ArrayType.Type.STRING;
            break;
        default:
            throw new IllegalStateException("Unknown array type \"" + arrayType + "\".");
    }
    array.setType(type);
}
Also used : Enum(org.dmg.pmml.SimpleSetPredicateDocument.SimpleSetPredicate.BooleanOperator.Enum) PMMLArrayType(org.knime.base.node.mine.decisiontree2.PMMLArrayType) ArrayType(org.dmg.pmml.ArrayType) PMMLArrayType(org.knime.base.node.mine.decisiontree2.PMMLArrayType) ArrayType(org.dmg.pmml.ArrayType) SchemaType(org.apache.xmlbeans.SchemaType) PMMLArrayType(org.knime.base.node.mine.decisiontree2.PMMLArrayType) PMMLSetOperator(org.knime.base.node.mine.decisiontree2.PMMLSetOperator)

Example 2 with PMMLSetOperator

use of org.knime.base.node.mine.decisiontree2.PMMLSetOperator in project knime-core by knime.

the class ConditionExporter method setValuesFromPMMLSimpleSetPredicate.

private void setValuesFromPMMLSimpleSetPredicate(final SimpleSetPredicate to, final PMMLSimpleSetPredicate from) {
    to.setField(m_derivedFieldMapper.getDerivedFieldName(from.getSplitAttribute()));
    final Enum operator;
    final PMMLSetOperator setOp = from.getSetOperator();
    switch(setOp) {
        case IS_IN:
            operator = SimpleSetPredicate.BooleanOperator.IS_IN;
            break;
        case IS_NOT_IN:
            operator = SimpleSetPredicate.BooleanOperator.IS_NOT_IN;
            break;
        default:
            throw new IllegalStateException("Unknown set operator \"" + setOp + "\".");
    }
    to.setBooleanOperator(operator);
    final Set<String> values = from.getValues();
    ArrayType array = to.addNewArray();
    array.setN(BigInteger.valueOf(values.size()));
    org.w3c.dom.Node arrayNode = array.getDomNode();
    arrayNode.appendChild(arrayNode.getOwnerDocument().createTextNode(setToWhitspaceSeparatedString(values)));
    final org.dmg.pmml.ArrayType.Type.Enum type;
    final PMMLArrayType arrayType = from.getArrayType();
    switch(arrayType) {
        case INT:
            type = ArrayType.Type.INT;
            break;
        case REAL:
            type = ArrayType.Type.REAL;
            break;
        case STRING:
            type = ArrayType.Type.STRING;
            break;
        default:
            throw new IllegalStateException("Unknown array type \"" + arrayType + "\".");
    }
    array.setType(type);
}
Also used : Enum(org.dmg.pmml.SimpleSetPredicateDocument.SimpleSetPredicate.BooleanOperator.Enum) PMMLArrayType(org.knime.base.node.mine.decisiontree2.PMMLArrayType) ArrayType(org.dmg.pmml.ArrayType) PMMLArrayType(org.knime.base.node.mine.decisiontree2.PMMLArrayType) ArrayType(org.dmg.pmml.ArrayType) PMMLArrayType(org.knime.base.node.mine.decisiontree2.PMMLArrayType) PMMLSetOperator(org.knime.base.node.mine.decisiontree2.PMMLSetOperator)

Aggregations

ArrayType (org.dmg.pmml.ArrayType)2 Enum (org.dmg.pmml.SimpleSetPredicateDocument.SimpleSetPredicate.BooleanOperator.Enum)2 PMMLArrayType (org.knime.base.node.mine.decisiontree2.PMMLArrayType)2 PMMLSetOperator (org.knime.base.node.mine.decisiontree2.PMMLSetOperator)2 SchemaType (org.apache.xmlbeans.SchemaType)1