Search in sources :

Example 6 with TreeNodeColumnCondition

use of org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition in project knime-core by knime.

the class LiteralConditionParser method handleSimplePredicate.

private TreeNodeColumnCondition handleSimplePredicate(final SimplePredicate simplePred, final boolean acceptsMissings) {
    String field = simplePred.getField();
    if (m_metaDataMapper.isNominal(field)) {
        NominalAttributeColumnHelper colHelper = m_metaDataMapper.getNominalColumnHelper(field);
        return new TreeNodeNominalCondition(colHelper.getMetaData(), colHelper.getRepresentation(simplePred.getValue()).getAssignedInteger(), acceptsMissings);
    } else {
        TreeNumericColumnMetaData metaData = m_metaDataMapper.getNumericColumnHelper(field).getMetaData();
        double value = Double.parseDouble(simplePred.getValue());
        return new TreeNodeNumericCondition(metaData, value, parseNumericOperator(simplePred.getOperator()), acceptsMissings);
    }
}
Also used : TreeNumericColumnMetaData(org.knime.base.node.mine.treeensemble2.data.TreeNumericColumnMetaData) TreeNodeNumericCondition(org.knime.base.node.mine.treeensemble2.model.TreeNodeNumericCondition) TreeNodeNominalCondition(org.knime.base.node.mine.treeensemble2.model.TreeNodeNominalCondition)

Example 7 with TreeNodeColumnCondition

use of org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition in project knime-core by knime.

the class LiteralConditionParser method parseSurrogateCompound.

private AbstractTreeNodeSurrogateCondition parseSurrogateCompound(final CompoundPredicate compound) {
    // PMML requires us to realize surrogates as a chain of compound condition because it doesn't enforce an order
    // among the predicates in the surrogate condition
    List<TreeNodeColumnCondition> conds = new ArrayList<>();
    boolean defaultResponse = unpackSurrogateChainIntoList(compound, conds);
    CheckUtils.checkArgument(!conds.isEmpty(), "The surrogate conditon '%s' contains no column conditions.", compound);
    return conds.size() > 1 ? new TreeNodeSurrogateCondition(conds.toArray(new TreeNodeColumnCondition[conds.size()]), defaultResponse) : new TreeNodeSurrogateOnlyDefDirCondition(conds.get(0), defaultResponse);
}
Also used : TreeNodeSurrogateCondition(org.knime.base.node.mine.treeensemble2.model.TreeNodeSurrogateCondition) AbstractTreeNodeSurrogateCondition(org.knime.base.node.mine.treeensemble2.model.AbstractTreeNodeSurrogateCondition) TreeNodeSurrogateOnlyDefDirCondition(org.knime.base.node.mine.treeensemble2.model.TreeNodeSurrogateOnlyDefDirCondition) TreeNodeColumnCondition(org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition) ArrayList(java.util.ArrayList)

Example 8 with TreeNodeColumnCondition

use of org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition in project knime-core by knime.

the class ConditionExporter method exportCondition.

void exportCondition(final TreeNodeCondition condition, final Node pmmlNode) {
    if (condition instanceof TreeNodeTrueCondition) {
        pmmlNode.addNewTrue();
    } else if (condition instanceof TreeNodeColumnCondition) {
        final TreeNodeColumnCondition colCondition = (TreeNodeColumnCondition) condition;
        exportColumnCondition(colCondition, pmmlNode);
    } else if (condition instanceof AbstractTreeNodeSurrogateCondition) {
        final AbstractTreeNodeSurrogateCondition surrogateCond = (AbstractTreeNodeSurrogateCondition) condition;
        setValuesFromPMMLCompoundPredicate(pmmlNode.addNewCompoundPredicate(), surrogateCond.toPMMLPredicate());
    } else {
        throw new IllegalStateException("Unsupported condition (not implemented): " + condition.getClass().getSimpleName());
    }
}
Also used : TreeNodeColumnCondition(org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition) TreeNodeTrueCondition(org.knime.base.node.mine.treeensemble2.model.TreeNodeTrueCondition) AbstractTreeNodeSurrogateCondition(org.knime.base.node.mine.treeensemble2.model.AbstractTreeNodeSurrogateCondition)

Aggregations

TreeNodeColumnCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeColumnCondition)4 AbstractTreeNodeSurrogateCondition (org.knime.base.node.mine.treeensemble2.model.AbstractTreeNodeSurrogateCondition)3 TreeNodeCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeCondition)3 TreeNodeSurrogateCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeSurrogateCondition)3 TreeNodeSurrogateOnlyDefDirCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeSurrogateOnlyDefDirCondition)3 ArrayList (java.util.ArrayList)2 BitSet (java.util.BitSet)2 TreeAttributeColumnData (org.knime.base.node.mine.treeensemble2.data.TreeAttributeColumnData)2 ScoreDistribution (org.dmg.pmml.ScoreDistributionDocument.ScoreDistribution)1 NominalValueRepresentation (org.knime.base.node.mine.treeensemble2.data.NominalValueRepresentation)1 TreeNominalColumnMetaData (org.knime.base.node.mine.treeensemble2.data.TreeNominalColumnMetaData)1 TreeNumericColumnMetaData (org.knime.base.node.mine.treeensemble2.data.TreeNumericColumnMetaData)1 TreeNodeClassification (org.knime.base.node.mine.treeensemble2.model.TreeNodeClassification)1 TreeNodeNominalBinaryCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeNominalBinaryCondition)1 TreeNodeNominalCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeNominalCondition)1 TreeNodeNumericCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeNumericCondition)1 TreeNodeTrueCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeTrueCondition)1